mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-02-23 19:49:43 +01:00
* Remove unused com interface * Remove unused file * Remove unused file * Remove unused file --------- Co-authored-by: Yu Leng (from Dev Box) <yuleng@microsoft.com>
33 lines
908 B
C#
33 lines
908 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 Microsoft.UI.Dispatching;
|
|
|
|
namespace Microsoft.CmdPal.Common.Helpers;
|
|
|
|
public static partial class NativeEventWaiter
|
|
{
|
|
public static void WaitForEventLoop(string eventName, Action callback)
|
|
{
|
|
var dispatcherQueue = DispatcherQueue.GetForCurrentThread();
|
|
var t = new Thread(() =>
|
|
{
|
|
var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, eventName);
|
|
while (true)
|
|
{
|
|
if (eventHandle.WaitOne())
|
|
{
|
|
dispatcherQueue.TryEnqueue(() => callback());
|
|
}
|
|
}
|
|
});
|
|
|
|
t.IsBackground = true;
|
|
t.Start();
|
|
}
|
|
}
|