public static ThreadPoolCallbackWrapper Enter() { return(new ThreadPoolCallbackWrapper { _currentThread = RuntimeThread.InitializeThreadPoolThread(), }); }
private static void LongRunningWorkCallback(IntPtr instance, IntPtr context) { RuntimeThread.InitializeThreadPoolThread(); GCHandle gcHandle = GCHandle.FromIntPtr(context); Action callback = (Action)gcHandle.Target; gcHandle.Free(); callback(); }
private static IntPtr ThreadPoolDispatchCallback(IntPtr context) { RuntimeThread.InitializeThreadPoolThread(); do { // Handle pending requests ThreadPoolWorkQueue.Dispatch(); // Wait for new requests to arrive s_semaphore.Wait(); } while (true); }
internal static void RegisteredWaitCallback(IntPtr instance, IntPtr context, IntPtr wait, uint waitResult) { RuntimeThread.InitializeThreadPoolThread(); GCHandle handle = (GCHandle)context; RegisteredWaitHandle registeredWaitHandle = (RegisteredWaitHandle)handle.Target; Debug.Assert((handle == registeredWaitHandle._gcHandle) && (wait == registeredWaitHandle._tpWait)); bool timedOut = (waitResult == (uint)Interop.Constants.WaitTimeout); registeredWaitHandle.PerformCallback(timedOut); }
private static unsafe void OnNativeIOCompleted(IntPtr instance, IntPtr context, IntPtr overlappedPtr, uint ioResult, UIntPtr numberOfBytesTransferred, IntPtr ioPtr) { RuntimeThread.InitializeThreadPoolThread(); Win32ThreadPoolNativeOverlapped *overlapped = (Win32ThreadPoolNativeOverlapped *)overlappedPtr; ThreadPoolBoundHandle boundHandle = overlapped->Data._boundHandle; if (boundHandle == null) { throw new InvalidOperationException(SR.Argument_NativeOverlappedAlreadyFree); } boundHandle.Release(); Win32ThreadPoolNativeOverlapped.CompleteWithCallback(ioResult, (uint)numberOfBytesTransferred, overlapped); }
private static void DispatchCallback(IntPtr instance, IntPtr context, IntPtr work) { RuntimeThread.InitializeThreadPoolThread(); Debug.Assert(s_work == work); ThreadPoolWorkQueue.Dispatch(); }
private static void TimerCallback(IntPtr instance, IntPtr context, IntPtr timer) { RuntimeThread.InitializeThreadPoolThread(); Instance.FireNextTimers(); }