/// <summary> /// Ensures that the hidden window is initialized and /// listening for messages. /// </summary> private static void EnsureInitialized() { if (_window == null) { lock (_lock) { if (_window == null) { using (ManualResetEvent mre = new ManualResetEvent(false)) { // Start the windowless message pump // and make sure it is active before the // main thread resumes. Thread t = new Thread((ThreadStart) delegate { _window = new PowerRegWindow(); mre.Set(); _window.MessageLoop(); }); t.Name = "Power Management message loop"; t.IsBackground = true; t.Start(); mre.WaitOne(); } } } } }
/// <summary> /// Ensures that the hidden window is initialized and /// listening for messages. /// </summary> private static void EnsureInitialized() { if (_window == null) { lock (_lock) { if (_window == null) { using (ManualResetEvent mre = new ManualResetEvent(false)) { // Start the windowless message pump // and make sure it is active before the // main thread resumes. Thread t = new Thread((ThreadStart)delegate { _window = new PowerRegWindow(); mre.Set(); _window.MessageLoop(); }); t.Name = "Power Management message loop"; t.IsBackground = true; t.Start(); mre.WaitOne(); } } } } }
/// <summary> /// Ensures that the hidden window is initialized and /// listening for messages. /// </summary> private static void EnsureInitialized() { lock (lockObject) { if (window == null) { // Create a new hidden window to listen // for power management related window messages. window = new PowerRegWindow(); } } }