/
githubmirror
/
PowerToys
Обзор
Документация
Войти
/
githubmirror
/
PowerToys
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/common/Common.UI/NativeEventWaiter.cs
33 строки
1 KB
Stefan Markovic
[General]Fix infinite loop: AutoReset global event in NativeEventWaiter (#26287)
25 май 2023, 18:19
Не верифицирован
25 май 2023, 18:19
6f56b35
Код
Авторство
О чём код?
// 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 Dispatcher = System.Windows.Threading.Dispatcher; namespace Common.UI { public static class NativeEventWaiter { public static void WaitForEventLoop(string eventName, Action callback, Dispatcher dispatcher, CancellationToken cancel) { new Thread(() => { var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, eventName); while (true) { if (WaitHandle.WaitAny(new WaitHandle[] { cancel.WaitHandle, eventHandle }) == 1) { dispatcher.BeginInvoke(callback); } else { return; } } }).Start(); } } }