本文整理汇总了C#中IOCompletionCallback类的典型用法代码示例。如果您正苦于以下问题:C# IOCompletionCallback类的具体用法?C# IOCompletionCallback怎么用?C# IOCompletionCallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IOCompletionCallback类属于命名空间,在下文中一共展示了IOCompletionCallback类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: _IOCompletionCallback
internal _IOCompletionCallback(IOCompletionCallback ioCompletionCallback, ref StackCrawlMark stackMark)
{
_ioCompletionCallback = ioCompletionCallback;
// clone the exection context
_executionContext = ExecutionContext.Capture(ref stackMark);
ExecutionContext.ClearSyncContext(_executionContext);
}
示例2: PreAllocatedOverlapped
public unsafe PreAllocatedOverlapped(IOCompletionCallback callback, object state, object pinData)
{
if (callback == null)
throw new ArgumentNullException(nameof(callback));
_overlapped = Win32ThreadPoolNativeOverlapped.Allocate(callback, state, pinData, this);
}
示例3: OverlappedCache
internal unsafe OverlappedCache(Overlapped overlapped, object pinnedObjects, IOCompletionCallback callback, bool alreadyTriedCast)
{
this.m_Overlapped = overlapped;
this.m_PinnedObjects = pinnedObjects;
this.m_PinnedObjectsArray = (alreadyTriedCast ? null : new object[0]);
this.m_NativeOverlapped = new SafeNativeOverlapped((IntPtr)((void*)overlapped.UnsafePack(callback, pinnedObjects)));
}
示例4: PreAllocatedOverlapped
public unsafe PreAllocatedOverlapped(IOCompletionCallback callback, object state, object pinData)
{
if (callback == null)
throw new ArgumentNullException("callback");
_overlapped = new ThreadPoolBoundHandleOverlapped(callback, state, pinData, this);
}
示例5: OverlappedContext
public OverlappedContext()
{
if (OverlappedContext.completeCallback == null)
{
OverlappedContext.completeCallback = Fx.ThunkCallback(new IOCompletionCallback(CompleteCallback));
}
if (OverlappedContext.eventCallback == null)
{
OverlappedContext.eventCallback = Fx.ThunkCallback(new WaitOrTimerCallback(EventCallback));
}
if (OverlappedContext.cleanupCallback == null)
{
OverlappedContext.cleanupCallback = Fx.ThunkCallback(new WaitOrTimerCallback(CleanupCallback));
}
this.bufferHolder = new object[] { OverlappedContext.dummyBuffer };
this.overlapped = new Overlapped();
this.nativeOverlapped = this.overlapped.UnsafePack(OverlappedContext.completeCallback, this.bufferHolder);
// When replacing the buffer, we need to provoke the CLR to fix up the handle of the pin.
this.pinnedHandle = GCHandle.FromIntPtr(*((IntPtr*)nativeOverlapped +
(IntPtr.Size == 4 ? HandleOffsetFromOverlapped32 : HandleOffsetFromOverlapped64)));
this.pinnedTarget = this.pinnedHandle.Target;
// Create the permanently rooted holder and put it in the Overlapped.
this.rootedHolder = new RootedHolder();
this.overlapped.AsyncResult = rootedHolder;
}
示例6: OverlappedCache
internal OverlappedCache(System.Threading.Overlapped overlapped, object pinnedObjects, IOCompletionCallback callback, bool alreadyTriedCast)
{
this.m_Overlapped = overlapped;
this.m_PinnedObjects = pinnedObjects;
this.m_PinnedObjectsArray = alreadyTriedCast ? null : NclConstants.EmptyObjectArray;
this.m_NativeOverlapped = new SafeNativeOverlapped(overlapped.UnsafePack(callback, pinnedObjects));
}
示例7: Pack
internal unsafe NativeOverlapped* Pack(IOCompletionCallback iocb, object userData)
{
if (!this.m_pinSelf.IsNull())
{
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_Overlapped_Pack"));
}
StackCrawlMark lookForMyCaller = StackCrawlMark.LookForMyCaller;
if (iocb != null)
{
this.m_iocbHelper = new _IOCompletionCallback(iocb, ref lookForMyCaller);
this.m_iocb = iocb;
}
else
{
this.m_iocbHelper = null;
this.m_iocb = null;
}
this.m_userObject = userData;
if (this.m_userObject != null)
{
if (this.m_userObject.GetType() == typeof(object[]))
{
this.m_isArray = 1;
}
else
{
this.m_isArray = 0;
}
}
return this.AllocateNativeOverlapped();
}
示例8: _IOCompletionCallback
internal _IOCompletionCallback(IOCompletionCallback ioCompletionCallback, ref StackCrawlMark stackMark)
{
_ioCompletionCallback = ioCompletionCallback;
// clone the exection context
_executionContext = ExecutionContext.Capture(
ref stackMark,
ExecutionContext.CaptureOptions.IgnoreSyncCtx | ExecutionContext.CaptureOptions.OptimizeDefaultCase);
}
示例9: ThreadPoolBoundHandleOverlapped
public unsafe ThreadPoolBoundHandleOverlapped(IOCompletionCallback callback, object state, object pinData, PreAllocatedOverlapped preAllocated)
{
_userCallback = callback;
_userState = state;
_preAllocated = preAllocated;
_nativeOverlapped = Pack(CompletionCallback, pinData);
_nativeOverlapped->OffsetLow = 0; // CLR reuses NativeOverlapped instances and does not reset these
_nativeOverlapped->OffsetHigh = 0;
}
示例10: Allocate
internal unsafe static Win32ThreadPoolNativeOverlapped* Allocate(IOCompletionCallback callback, object state, object pinData, PreAllocatedOverlapped preAllocated)
{
Win32ThreadPoolNativeOverlapped* overlapped = AllocateNew();
try
{
overlapped->SetData(callback, state, pinData, preAllocated);
}
catch
{
Free(overlapped);
throw;
}
return overlapped;
}
示例11: PipeServiceListener
static unsafe PipeServiceListener()
{
pipeStreamType = typeof(System.IO.Pipes.PipeStream);
FieldInfo ioCallbackField = pipeStreamType.GetField("IOCallback", BindingFlags.GetField | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.IgnoreReturn);
pipeStreamAsyncPSCallback = (IOCompletionCallback)ioCallbackField.GetValue(null);
ioCallbackField.SetValue(null, new IOCompletionCallback(pipeStreamAsyncPSCallbackWrapper));
// 修正 WaitForConnection 的回调函数中的异常
pipeServerStreamType = typeof(System.IO.Pipes.NamedPipeServerStream);
ioCallbackField = pipeServerStreamType.GetField("WaitForConnectionCallback", BindingFlags.GetField | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.IgnoreReturn);
pSSAsyncWaitForConnectionCallback = (IOCompletionCallback)ioCallbackField.GetValue(null);
ioCallbackField.SetValue(null, new IOCompletionCallback(pSSAsyncWaitForConnectionCallbackWrapper));
}
示例12: AllocateNativeOverlapped
public unsafe NativeOverlapped* AllocateNativeOverlapped(IOCompletionCallback callback, object state, object pinData)
{
if (callback == null)
throw new ArgumentNullException("callback");
AddRef();
try
{
Win32ThreadPoolNativeOverlapped* overlapped = Win32ThreadPoolNativeOverlapped.Allocate(callback, state, pinData, preAllocated: null);
overlapped->Data._boundHandle = this;
Interop.mincore.StartThreadpoolIo(_threadPoolHandle);
return Win32ThreadPoolNativeOverlapped.ToNativeOverlapped(overlapped);
}
catch
{
Release();
throw;
}
}
示例13: OverlappedContext
public unsafe OverlappedContext()
{
if (completeCallback == null)
{
completeCallback = Fx.ThunkCallback(new IOCompletionCallback(OverlappedContext.CompleteCallback));
}
if (eventCallback == null)
{
eventCallback = Fx.ThunkCallback(new WaitOrTimerCallback(OverlappedContext.EventCallback));
}
if (cleanupCallback == null)
{
cleanupCallback = Fx.ThunkCallback(new WaitOrTimerCallback(OverlappedContext.CleanupCallback));
}
this.bufferHolder = new object[] { dummyBuffer };
this.overlapped = new Overlapped();
this.nativeOverlapped = this.overlapped.UnsafePack(completeCallback, this.bufferHolder);
this.pinnedHandle = GCHandle.FromIntPtr(*((IntPtr*) (this.nativeOverlapped + (((IntPtr.Size == 4) ? -4 : -3) * sizeof(IntPtr)))));
this.pinnedTarget = this.pinnedHandle.Target;
this.rootedHolder = new RootedHolder();
this.overlapped.AsyncResult = this.rootedHolder;
}
示例14: UnsafePack
unsafe internal NativeOverlapped* UnsafePack(IOCompletionCallback iocb, Object userData)
{
if (!m_pinSelf.IsNull()) {
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_Overlapped_Pack"));
}
m_userObject = userData;
if (m_userObject != null)
{
if (m_userObject.GetType() == typeof(Object[]))
{
m_isArray = 1;
}
else
{
m_isArray = 0;
}
}
m_iocb = iocb;
m_iocbHelper = null;
return AllocateNativeOverlapped();
}
示例15: BindIoCompletionCallback
public static extern bool BindIoCompletionCallback(
SafeCloseSocket socketHandle,
IOCompletionCallback function,
Int32 flags
);