mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 12:18:50 +02:00
[chore] fix line endings (#6307)
This commit is contained in:
@@ -1,18 +1,18 @@
|
|||||||
// Copyright (c) Microsoft Corporation
|
// Copyright (c) Microsoft Corporation
|
||||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace ManagedCommon
|
namespace ManagedCommon
|
||||||
{
|
{
|
||||||
internal static class NativeMethods
|
internal static class NativeMethods
|
||||||
{
|
{
|
||||||
[DllImport("kernel32.dll", SetLastError = true)]
|
[DllImport("kernel32.dll", SetLastError = true)]
|
||||||
internal static extern IntPtr OpenProcess(uint processAccess, bool bInheritHandle, int processId);
|
internal static extern IntPtr OpenProcess(uint processAccess, bool bInheritHandle, int processId);
|
||||||
|
|
||||||
[DllImport("kernel32.dll", SetLastError = true)]
|
[DllImport("kernel32.dll", SetLastError = true)]
|
||||||
internal static extern uint WaitForSingleObject(IntPtr hHandle, uint dwMilliseconds);
|
internal static extern uint WaitForSingleObject(IntPtr hHandle, uint dwMilliseconds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,37 +1,37 @@
|
|||||||
// Copyright (c) Microsoft Corporation
|
// Copyright (c) Microsoft Corporation
|
||||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.PowerToys.Telemetry;
|
using Microsoft.PowerToys.Telemetry;
|
||||||
using Microsoft.PowerToys.Telemetry.Events;
|
using Microsoft.PowerToys.Telemetry.Events;
|
||||||
|
|
||||||
namespace ManagedCommon
|
namespace ManagedCommon
|
||||||
{
|
{
|
||||||
public static class RunnerHelper
|
public static class RunnerHelper
|
||||||
{
|
{
|
||||||
public static void WaitForPowerToysRunner(int powerToysPID, Action act)
|
public static void WaitForPowerToysRunner(int powerToysPID, Action act)
|
||||||
{
|
{
|
||||||
var stackTrace = new StackTrace();
|
var stackTrace = new StackTrace();
|
||||||
var assembly = Assembly.GetCallingAssembly().GetName();
|
var assembly = Assembly.GetCallingAssembly().GetName();
|
||||||
var callingMethod = stackTrace.GetFrame(1).GetMethod().Name;
|
var callingMethod = stackTrace.GetFrame(1).GetMethod().Name;
|
||||||
PowerToysTelemetry.Log.WriteEvent(new DebugEvent() { Message = $"[{assembly}][{callingMethod}]WaitForPowerToysRunner waiting for Event powerToysPID={powerToysPID}" });
|
PowerToysTelemetry.Log.WriteEvent(new DebugEvent() { Message = $"[{assembly}][{callingMethod}]WaitForPowerToysRunner waiting for Event powerToysPID={powerToysPID}" });
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
const uint INFINITE = 0xFFFFFFFF;
|
const uint INFINITE = 0xFFFFFFFF;
|
||||||
const uint WAIT_OBJECT_0 = 0x00000000;
|
const uint WAIT_OBJECT_0 = 0x00000000;
|
||||||
const uint SYNCHRONIZE = 0x00100000;
|
const uint SYNCHRONIZE = 0x00100000;
|
||||||
|
|
||||||
IntPtr powerToysProcHandle = NativeMethods.OpenProcess(SYNCHRONIZE, false, powerToysPID);
|
IntPtr powerToysProcHandle = NativeMethods.OpenProcess(SYNCHRONIZE, false, powerToysPID);
|
||||||
if (NativeMethods.WaitForSingleObject(powerToysProcHandle, INFINITE) == WAIT_OBJECT_0)
|
if (NativeMethods.WaitForSingleObject(powerToysProcHandle, INFINITE) == WAIT_OBJECT_0)
|
||||||
{
|
{
|
||||||
PowerToysTelemetry.Log.WriteEvent(new DebugEvent() { Message = $"[{assembly}][{callingMethod}]WaitForPowerToysRunner Event Notified powerToysPID={powerToysPID}" });
|
PowerToysTelemetry.Log.WriteEvent(new DebugEvent() { Message = $"[{assembly}][{callingMethod}]WaitForPowerToysRunner Event Notified powerToysPID={powerToysPID}" });
|
||||||
act.Invoke();
|
act.Invoke();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user