Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6910795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:51:38+00:00 2026-05-27T08:51:38+00:00

I wanted to pause a VideoStream from a Kinect. The button has the following

  • 0

I wanted to pause a VideoStream from a Kinect. The button has the following code:

if (capturing==0)
{
    try
    {
        // Signing the Event for Image frame ready
        nuiRuntime.VideoFrameReady += new EventHandler<ImageFrameReadyEventArgs>(nuiRuntime_VideoFrameReady);
        nuiRuntime.DepthFrameReady += new EventHandler<ImageFrameReadyEventArgs>(nuiRuntime_DepthFrameReady);
        nuiRuntime.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color);
        nuiRuntime.DepthStream.Open(ImageStreamType.Depth, 2, ImageResolution.Resolution320x240, ImageType.Depth);
    }
    catch
    {
        Dialogs.ShowWarning("An Error occured. Check, if the Kinect is connected properly.");
    }
    finally
    {
        capturing = 2;
    }
}
else if (capturing == 1)
{
    nuiRuntime.VideoFrameReady += new EventHandler<ImageFrameReadyEventArgs>(nuiRuntime_VideoFrameReady);
    nuiRuntime.DepthFrameReady += new EventHandler<ImageFrameReadyEventArgs>(nuiRuntime_DepthFrameReady);
    capturing = 2;//go on after break 
}
else
{
    nuiRuntime.VideoFrameReady -= new EventHandler<ImageFrameReadyEventArgs>(nuiRuntime_VideoFrameReady);
    nuiRuntime.DepthFrameReady -= nuiRuntime_DepthFrameReady;
    capturing = 1;//pause
}

I dont think, it is hard to understand.
States: 0, Kinect is uninitialized, do so
1, Kinect is paused, go on
2, Kinect is normally capturing

But: when the “else” is executed, the Image in the GUI (WPF.Image) still shows a moving video-stream. In the “else” are 2 ways, I tried to make it a break. Then there should be displayed a still picture.

Of course, I simply can say the EventHandler: If we are in state 1, simply don’t work on the picture, but I don´t think, this is a clean way of implementation.

Can anyone see my mistake?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:51:39+00:00Added an answer on May 27, 2026 at 8:51 am

    Event handlers are reference types (delegates), the one you add to the event

    nuiRuntime.VideoFrameReady += new EventHandler<ImageFrameReadyEventArgs>(nuiRuntime_VideoFrameReady);
    

    is not the same one you remove from it:

    nuiRuntime.VideoFrameReady -= new EventHandler<ImageFrameReadyEventArgs>(nuiRuntime_VideoFrameReady);
    

    The fix is simple, keep the handler instance somewhere:

    var handler = new EventHandler<ImageFrameReadyEventArgs>(nuiRuntime_VideoFrameReady);
    

    then add/remove the same instance:

    nuiRuntime.VideoFrameReady += handler;
    nuiRuntime.VideoFrameReady -= handler;
    

    BTW, the code you use in the “else” block:

    nuiRuntime.DepthFrameReady -= nuiRuntime_DepthFrameReady;
    

    is the same as:

    nuiRuntime.DepthFrameReady -= new EventHandler<ImageFrameReadyEventArgs>(nuiRuntime_DepthFrameReady);
    

    The compiler simple do the new EventHandler<> things for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just wanted to pause in an F# console application, so I wrote: Console.ReadKey()
Wanted to know if someone had a suggestion on code or maybe there's a
I wanted to write a timer in java.which will do the following: when program
I have the following batch script from Wikipedia: @echo off for /R C:\Users\Admin\Ordner %%f
when i try to parse the response returned from a web service i got
I'm following a tutorial and it's working fine but if I wanted to parse
I wanted to use threads in my code and thought that the upcoming C++0x
this is my code. i wanted to print all my list datas. but i
I've designed a code that sends file from android mobile to PC. The code
The following code: #include <cstdlib> #include <iostream> using namespace std; int function(void) { static

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.