Example #1
0
        private void CleanUp()
        {
            if (FHandGenerator != null)
            {
                FHandGenerator.HandCreate  -= FHands_HandCreate;
                FHandGenerator.HandDestroy -= FHands_HandDestroy;
                FHandGenerator.HandUpdate  -= FHands_HandUpdate;

                FHandGenerator.Dispose();
                FHandGenerator = null;
            }

            FTrackedStartPositions.Clear();
            FTrackedHands.Clear();
        }
Example #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);
        }