hello, in the following code
private void Window_Loaded(object sender, RoutedEventArgs e)
{
// check if any kinect is available
if (Sensors.Count == 0)
{
MessageBox.Show("no sensor is available for listening !!");
Application.Current.Shutdown();
}
///
///
PromptBuilder pb1 = new PromptBuilder();
pb1.AppendText("HELLO", System.Speech.Synthesis.PromptVolume.Loud);
this.speaker(pb1);
}
the last three lines are executed even though the ' if ' condition is satisfied! can anyone explain me why ? i think the application should shutdown .

VulpesPosted Jan 16, 2015, 7:04 AM
I tend to prefer this to using 'else' if there would be a lot of code to indent as I like to keep indentation to a minimum. However, with just 3 lines it's a matter of taste which you use.
Sanju SinghPosted Jan 18, 2015, 10:11 PM
Sanju SinghPosted Jan 18, 2015, 10:01 PM
VulpesPosted Jan 17, 2015, 8:18 AM
Manish Kumar ChoudharyPosted Jan 17, 2015, 3:44 AM
Sanju SinghPosted Jan 17, 2015, 3:42 AM
Manish Kumar ChoudharyPosted Jan 17, 2015, 1:24 AM
Application.Exit();
and, if that doesn't work:
Environment.Exit(1);
Before calling either of these close all connections manually and releasing unmanaged resources by calling Dispose() on any object still in scope which implements IDisposable.
Sanju SinghPosted Jan 17, 2015, 12:51 AM
Sanju SinghPosted Jan 17, 2015, 12:48 AM
Manish Kumar ChoudharyPosted Jan 16, 2015, 11:22 PM
break;
Sanju SinghPosted Jan 16, 2015, 10:16 PM
Sanju SinghPosted Jan 16, 2015, 10:15 PM
Manish Kumar ChoudharyPosted Jan 16, 2015, 1:30 AM
Hi sanju singh,
private void Window_Loaded(object sender, RoutedEventArgs e)
{
// check if any kinect is available
if (Sensors.Count == 0)
{
MessageBox.Show("no sensor is available for listening !!");
Application.Current.Shutdown();
}
///
///
else{
PromptBuilder pb1 = new PromptBuilder();
pb1.AppendText("HELLO", System.Speech.Synthesis.PromptVolume.Loud);
this.speaker(pb1);
}
}
Now it will not execute actually you did not put those condition inside else block so whenever if condition over after that last three lines will execute. The execution process is top to Bottom so after finishing the if block execution those three line will execute