none
Looking for a C# console app example using statuschanged RRS feed

  • Question

  • Hi all

    Im looking for a C# console application example using the Microsoft.Kinect.Toolkit from SDK 1.5 or any other way reliable  to handle the kinect statuschanged event.

    As i understood handling massages in a console application is a bit more complicated so any suggestions where to find a code example would be highly appreciated.

    Kind regards 

    Bill 

    Saturday, June 2, 2012 9:46 AM

Answers

  • Here's the entire source for a program that should help you with this question:

    namespace KinectStatusConsole
    {
        class Program
        {
            static void Main(string[] args)
            {
                System.Console.WriteLine("Listening for status.  Press any key to exit.");
    
                Microsoft.Kinect.KinectSensor.KinectSensors.StatusChanged +=
                    (sender, eventArgs) =>
                    System.Console.WriteLine("Status Changed: Sensor {0}, Status {1}", 
                    (eventArgs.Sensor == null) ? "<none>" : eventArgs.Sensor.DeviceConnectionId,
                    eventArgs.Status);
    
                System.Console.ReadKey();
            }
        }
    }

    -Adam Smith [MSFT]


    Wednesday, June 6, 2012 1:03 AM

All replies

  • To use events in your application, you have to use a framework that will process Window messages. I am not aware of a supported way to do this from a c# console application. It would be best to understand why you need to do this from a console application. What is your scenario as what you may be doing may not be a tested/supported?

    The toolkit is designed for use with WPF and not required for all Kinect based applications. You could just keep polling the Status property of the KinectSensor object, but this goes back to my other question of your scenario, why do you need to do this? 

    Tuesday, June 5, 2012 11:14 PM
  • Here's the entire source for a program that should help you with this question:

    namespace KinectStatusConsole
    {
        class Program
        {
            static void Main(string[] args)
            {
                System.Console.WriteLine("Listening for status.  Press any key to exit.");
    
                Microsoft.Kinect.KinectSensor.KinectSensors.StatusChanged +=
                    (sender, eventArgs) =>
                    System.Console.WriteLine("Status Changed: Sensor {0}, Status {1}", 
                    (eventArgs.Sensor == null) ? "<none>" : eventArgs.Sensor.DeviceConnectionId,
                    eventArgs.Status);
    
                System.Console.ReadKey();
            }
        }
    }

    -Adam Smith [MSFT]


    Wednesday, June 6, 2012 1:03 AM