Ejemplo n.º 1
0
        private void CloseContext()
        {
            if (FContext != null)
            {
                FContext.StopGeneratingAll();
                FContext.ErrorStateChanged -= FContext_ErrorStateChanged;

                if (FDepthGenerator != null)
                {
                    FDepthGenerator.Dispose();
                    FDepthGenerator = null;
                }

                FContext.Release();
                FContext = null;
            }
        }
Ejemplo n.º 2
0
        private void CloseContext()
        {
            if (FUpdater != null && FUpdater.IsAlive)
            {
                //wait for threadloop to exit
                FRunning = false;
                FUpdater.Join();
            }

            if (FContext != null)
            {
                //FContext.WaitAndUpdateAll();
                FContext.StopGeneratingAll();
                FContext.ErrorStateChanged -= FContext_ErrorStateChanged;

                if (FHandGenerator != null)
                {
                    FHandGenerator.HandCreate  -= FHands_HandCreate;
                    FHandGenerator.HandDestroy -= FHands_HandDestroy;
                    FHandGenerator.HandUpdate  -= FHands_HandUpdate;

                    FHandGenerator.Dispose();
                    FHandGenerator = null;
                }

                if (FDepthGenerator != null)
                {
                    FDepthGenerator.Dispose();
                }

                if (FImageGenerator != null)
                {
                    FImageGenerator.Dispose();
                }

                FTrackedStartPositions.Clear();
                FTrackedHands.Clear();

                FContext.Release();
                FContext = null;
            }

            Marshal.FreeCoTaskMem(FBufferedImage);
        }