Example #1
0
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     if (myHandle != IntPtr.Zero)
     {
         HTCNativeMethods.HTCSensorClose(myHandle);
         myHandle = IntPtr.Zero;
     }
 }
Example #2
0
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
            if (myHandle != IntPtr.Zero)
            {
                HTCNativeMethods.HTCSensorClose(myHandle);
                myHandle = IntPtr.Zero;
            }

            // note: I noticed in Scott's code, on the shutdown he fires the "HTC_GSENSOR_SERVICESTART" event again.
            // I am guessing that is a bug in his code.
            // My theory is the service start/stop manage a reference count to the service.
            // Once it hits 0, the service is stopped.
            IntPtr hEvent = CreateEvent(IntPtr.Zero, true, false, "HTC_GSENSOR_SERVICESTOP");

            SetEvent(hEvent);
            CloseHandle(hEvent);
        }