/
githubmirror
/
PowerToys
Обзор
Документация
Войти
/
githubmirror
/
PowerToys
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/modules/ShortcutGuide/ShortcutGuide.Ui/Helpers/EventHelper.cs
48 строк
2 KB
Niels Laute
Shortcut Guide: Replace dual windows with single transparent overlay and add holding windows button (#48683)
27 июл 2026, 13:21
Не верифицирован
27 июл 2026, 13:21
346b498
Код
Авторство
О чём код?
// 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.Collections.Generic; using System.Text; using System.Threading; using ManagedCommon; namespace ShortcutGuide.Helpers { /// <summary> /// Helper class for Windows named event operations. /// Provides unified event signaling with consistent error handling and logging. /// </summary> public static class EventHelper { /// <summary> /// Signals a named event. Creates the event if it doesn't exist. /// </summary> /// <param name="eventName">The name of the event to signal.</param> /// <returns>True if the event was signaled successfully, false otherwise.</returns> public static bool SignalEvent(string eventName) { if (string.IsNullOrEmpty(eventName)) { Logger.LogWarning("[EventHelper] SignalEvent called with null or empty event name"); return false; } try { using var eventHandle = new EventWaitHandle( false, EventResetMode.AutoReset, eventName); eventHandle.Set(); return true; } catch (Exception ex) { Logger.LogError($"[EventHelper] Failed to signal event '{eventName}': {ex.Message}"); return false; } } } }