mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-21 15:27:55 +08:00
29 lines
831 B
C#
29 lines
831 B
C#
|
// Copyright (c) Microsoft Corporation
|
|||
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|||
|
// See the LICENSE file in the project root for more information.
|
|||
|
|
|||
|
using System;
|
|||
|
using System.Threading;
|
|||
|
using System.Windows;
|
|||
|
|
|||
|
namespace PowerLauncher.Helper
|
|||
|
{
|
|||
|
public static class NativeEventWaiter
|
|||
|
{
|
|||
|
public static void WaitForEventLoop(string eventName, Action callback)
|
|||
|
{
|
|||
|
new Thread(() =>
|
|||
|
{
|
|||
|
var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, eventName);
|
|||
|
while (true)
|
|||
|
{
|
|||
|
if (eventHandle.WaitOne())
|
|||
|
{
|
|||
|
Application.Current.Dispatcher.Invoke(callback);
|
|||
|
}
|
|||
|
}
|
|||
|
}).Start();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|