LOL, your question is all over the place
What do you mean by "application will start from the first programmatically"?
What do you mean by "the application should be stopped"?
But it sounds like you want to track state of your app.
You can start with an enum (States) with 2 states, Active and Inactive and have
A variable that holds the state (CurrentState)
A int to hold the count of frames since its been inactive (CurrentInactiveFrameCount)
A int to the maximum Inactive Frame Count (CurrentInactiveFrameCountMax)
, in your FrameReady event code, if there are any skeletons picked up change the CurrentState to States.Active else CurrentState to States.Inactive.
Below is basic pseudocode code
if(CurrentState is States.Active)
{
Process skeleton data as per normal
}
else
{
if(CurrentInactiveFrameCount < CurrentInactiveFrameCountMax)
{
if(CurrentInactiveFrameCount=0)
background colour = Brushes.SomeColour
CurrentInactiveFrameCount++
}
else
background colour = Brushes.OriginalColour
}
Just remember that the default is 30fps at 640x480, so your
CurrentInactiveFrameCountMax would be ROUGHLY 150 if you want the background colour to change for about 5 seconds
So neither your program nor the Kinect stop, it just changes state, and so changes behaviour.
If yous still not with me, then I can write a proper program that does all this when I get back home in a few days