public override bool Dispose() { #if (PocketPC) this._Status = ReceiverStatus.Disconnected; if (myHandle != IntPtr.Zero) { HTCSensorClose(myHandle); myHandle = IntPtr.Zero; } using (myOrientationState) { myOrientationState.Changed -= new ChangeEventHandler(myOrientationState_Changed); } myOrientationState = null; myOrientationChangedHandler = null; // 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); #endif return(true); }
public void Dispose() { if (myHandle != IntPtr.Zero) { HTCSensorClose(myHandle); myHandle = IntPtr.Zero; } using (myOrientationState) { myOrientationState.Changed -= new ChangeEventHandler(myOrientationState_Changed); } myOrientationState = null; myOrientationChangedHandler = null; // 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); }