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:
wj32
2009-10-12 02:21:30 +00:00
parent c82af812cc
commit 504ee67b17
896 changed files with 188819 additions and 0 deletions
@@ -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();
}
}
}