5 Replies Latest reply on Jan 30, 2017 12:24 PM by Intel Corporation

    SenseManager.Close() blocking in C# application

    phiip-barclay

      Hi,

       

      I am having an issue with stopping the streams of an SR300 from a C# app.  Streams are configured via the SenseManager and started using senseManager.StreamFrames(false); where the false indicated non-blocking mode.  This works fine and frames stream correctly.  To stop streaming, the documentation states Close() can be called at any time.  However, calls to senseManager.Close(); never seem to return.

       

      This issue seems almost exactly the same C# - SenseManager.StreamFrames(false) is not stopped by SenseManager.Close() .  In that thread the author had a workaround using the blocking version of StreamFrames(true) started in a separate thread, however, this doesn't seem to help in my case.

       

      Most of the c# sample apps dont seem to issue a Close() call, they just leave everything streaming until shutdown.

       

      Any ideas?

       

      Installed:

      intel_rs_sdk_mw_core_offline_11.0.27.1384.exe

      intel_rs_dcm_sr300_3.3.27.5718.exe

        • 1. Re: SenseManager.Close() blocking in C# application
          Intel Corporation
          This message was posted on behalf of Intel Corporation

          Hi phiip-barclay,

          Thank you for contacting us, we’ll try to help you solve this situation. I read the thread you linked and the problem is indeed very similar. My first suggestion was going to be to check the functions names of C# and C++, cause in some cases, they differ from one another.

          Also, which SDK are you using? The latest SDK release is SDK 2016 R3. In the link you posted, the issue was related to the SDK R2. We want to know if this issue persists on SDK R3 as well.

          We’ll be waiting on your response so we can have more information and see if we can help you out or if we should classify this as a bug.

          -Sergio
           

          • 2. Re: SenseManager.Close() blocking in C# application
            phiip-barclay

            Thanks for the response.

             

            The C# call to Close() is as per the documentation here: Intel® RealSense™ SDK 2016 R3 Documentation

             

             

            Version info:

            SDK 2016 R3 (11.0.27.1384)

            DCM SR300 (3.3.27.5718)

             

            Main code chunks:

             

            using RS = Intel.RealSense;

             

            private RS.Status InitCamera()

            {

                 RS.Status initStatus;

                 try

                 {

                      senseManager = RS.SenseManager.CreateInstance();

             

                      RS.SampleReader readerRGB = RS.SampleReader.Activate(senseManager);

                      readerRGB.EnableStream(Intel.RealSense.StreamType.STREAM_TYPE_COLOR, 640, 480, 30);

                      readerRGB.SampleArrived += OnNewSample;

                

                      RS.SampleReader readerDepth = RS.SampleReader.Activate(senseManager);

                      readerDepth.EnableStream(Intel.RealSense.StreamType.STREAM_TYPE_DEPTH, 640, 480, 30);

                      readerDepth.SampleArrived += OnNewSample;

                     

                      initStatus = senseManager.Init();

                 }

                 catch (Exception e)

                 {    

                      throw new Exception("Failed to initialize RSStreamingRGB : " + e.Message);

                 }

                 return initStatus;

            }

             

            public void StartStreaming()

            {

                 if (!initialized)

                      InitCamera();

             

                 // Either of these cause .Close() to block

                 //Task.Factory.StartNew(() => { senseManager.StreamFrames(true); });

                 senseManager.StreamFrames(false);

            }

             

            public void StopStreaming()

            {

                 senseManager.Close();

            }

             

            private void OnNewSample(object sender, RS.SampleArrivedEventArgs args)

            {

                 // Do some stuff with the fresh samples

            }

            • 3. Re: SenseManager.Close() blocking in C# application
              Intel Corporation
              This message was posted on behalf of Intel Corporation

              Thank you for providing the information we requested. We’ll do some research to try to find more information about this. We’ll contact you as soon as we have an update.

              Regards,
              -Sergio
               

              • 4. Re: SenseManager.Close() blocking in C# application
                Intel Corporation
                This message was posted on behalf of Intel Corporation

                Thank you for waiting. After doing some tests, we were unable to reproduce the issue of the application hanging because sensemanager.Close() did not return.
                To test this, I opened %RSSDK%/sample/core/RawStreams.cs/RawStreams.cs_vs2012_15.sln and navigated to raw_streams.cs file. In line 151 in the function StreamColorDepth() there is the line sm.Dispose();. When I add sm.Close() before Dispose it works fine. The application returns from Close and continues to Dispose.


                You can also try using sensemanager.Dispose() without using Close() and see if that is acceptable.

                Let us know your results.

                -Sergio
                 

                • 5. Re: SenseManager.Close() blocking in C# application
                  Intel Corporation
                  This message was posted on behalf of Intel Corporation

                  Hi phiip-barclay,

                  We were wondering if you had a chance to look at our previous suggestion. Please let us know if you still need assistance with this case.

                  -Sergio