mirror of
https://github.com/mirror/processhacker
synced 2026-06-08 16:03:24 +00:00
new ph-plugins branch
git-svn-id: svn://svn.code.sf.net/p/processhacker/code@2148 21ef857c-d57f-4fe0-8362-d861dc6d29cd
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using ProcessHacker.Native.Api;
|
||||
using ProcessHacker.Native.Objects;
|
||||
|
||||
namespace ProcessHacker.Native.Threading
|
||||
{
|
||||
public delegate void RegisterWaitCallback(object argument, bool timeout);
|
||||
|
||||
public static class NativeThreadPool
|
||||
{
|
||||
public static void QueueWorkItem(Action<object> work, object argument)
|
||||
{
|
||||
Win32.RtlQueueWorkItem((context) => work(argument), IntPtr.Zero, WtFlags.ExecuteDefault).ThrowIf();
|
||||
}
|
||||
|
||||
public static IntPtr RegisterWait(IntPtr handle, RegisterWaitCallback callback, object argument, int timeoutMilliseconds)
|
||||
{
|
||||
IntPtr waitHandle;
|
||||
|
||||
Win32.RtlRegisterWait(
|
||||
out waitHandle,
|
||||
handle,
|
||||
(context, timeout) => callback(argument, timeout),
|
||||
IntPtr.Zero,
|
||||
timeoutMilliseconds,
|
||||
WtFlags.ExecuteDefault
|
||||
).ThrowIf();
|
||||
|
||||
return waitHandle;
|
||||
}
|
||||
|
||||
public static void UnregisterWait(IntPtr waitHandle)
|
||||
{
|
||||
Win32.RtlDeregisterWait(waitHandle).ThrowIf();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user