none
A way to separate UI processing from Kinect processing RRS feed

  • Question

  • Like the title reads. I am just looking for a way - i guess for multithreading between

    the kinect process and the UI process. Thanks in advance!

    Sunday, August 28, 2011 4:54 PM

Answers

  • Actually, if you're using managed code, I'd suggest using SynchronizationContext class to communicate between kinect thread and UI thread instead of a global variable that you might have to explicitly lock to access safely. Both WPF and Windows Forms set a SynchronizationContext on the UI thread. When executing as part of main UI thread you can do

    SynchronizationContext context = SynchronizationContext.Current;

    and then pass the context to your other thread that is doing Kinect processing. Then when the kinect thread wants to send information to the UI thread you can do

    context.Send(delegate
    {
        // Your code here. This code actually gets executed in the main thread.
    }, null);

    Hope this helps,
    Eddy


    I'm here to help
    Friday, September 2, 2011 1:18 AM

All replies

  •  

    Hi Joseph, 

    I think you answered your own question there - multithreading.  Have your kinect process going on in its own thread and have your UI operating in another thread.  Keep a global variable or static or whatever works to communicate between the threads as needed.   Good luck with it!

     


    Susan
    Tuesday, August 30, 2011 1:59 PM
  • Actually, if you're using managed code, I'd suggest using SynchronizationContext class to communicate between kinect thread and UI thread instead of a global variable that you might have to explicitly lock to access safely. Both WPF and Windows Forms set a SynchronizationContext on the UI thread. When executing as part of main UI thread you can do

    SynchronizationContext context = SynchronizationContext.Current;

    and then pass the context to your other thread that is doing Kinect processing. Then when the kinect thread wants to send information to the UI thread you can do

    context.Send(delegate
    {
        // Your code here. This code actually gets executed in the main thread.
    }, null);

    Hope this helps,
    Eddy


    I'm here to help
    Friday, September 2, 2011 1:18 AM
  • Hello,

     

    I have been reading through this thread and it is helpful. I am hoping you can clarify what you meant in your comments regarding the content of the "context.send(delegate..." code snippet.

    You state that this code is executed in the main thread. If this is the case, how do I send code out to a daughter thread for processing?

     

    Thanks and Regards,

    DJ


    Don't make excuses; make improvements.
    Tuesday, November 22, 2011 2:30 AM