protected virtual void Dispose(bool disposing) { if (disposing) { lock (_threadlock) { _listeners.Remove(WindowHandle); if (_listeners.Count == 0) { CoreNativeMethods.PostMessage(WindowHandle, WindowMessage.Destroy, IntPtr.Zero, IntPtr.Zero); } } } }
private void CrossThreadCreateWindow() { if (_firstWindowHandle == IntPtr.Zero) { throw new InvalidOperationException(LocalizedMessages.MessageListenerNoWindowHandle); } lock (_crossThreadWindowLock) { CoreNativeMethods.PostMessage(_firstWindowHandle, (WindowMessage)CreateWindowMessage, IntPtr.Zero, IntPtr.Zero); Monitor.Wait(_crossThreadWindowLock); } WindowHandle = _tempHandle; }