本文整理汇总了C#中LazyAsyncResult.InvokeCallback方法的典型用法代码示例。如果您正苦于以下问题:C# LazyAsyncResult.InvokeCallback方法的具体用法?C# LazyAsyncResult.InvokeCallback怎么用?C# LazyAsyncResult.InvokeCallback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LazyAsyncResult
的用法示例。
在下文中一共展示了LazyAsyncResult.InvokeCallback方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BeginWrite
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, Object state)
{
Write(buffer, offset, count);
LazyAsyncResult ar = new LazyAsyncResult(null, state, callback);
ar.InvokeCallback(null);
return ar;
}
示例2: DoBeginAccept
private void DoBeginAccept(LazyAsyncResult asyncResult)
{
if (this.m_RightEndPoint == null)
throw new InvalidOperationException("net_sockets_mustbind");
if (!this.isListening)
throw new InvalidOperationException("net_sockets_mustlisten");
bool flag = false;
SocketError socketError = SocketError.Success;
Queue acceptQueue = this.GetAcceptQueue();
bool flag2 = false;
try
{
Monitor.Enter(this, ref flag2);
if (acceptQueue.Count == 0)
{
SocketAddress socketAddress = this.m_RightEndPoint.Serialize();
this.InternalSetBlocking(false);
SafeCloseSocket safeCloseSocket = null;
try
{
safeCloseSocket = SafeCloseSocket.Accept(this.m_Handle, socketAddress.m_Buffer, ref socketAddress.m_Size);
socketError = (SocketError)(safeCloseSocket.IsInvalid ? Marshal.GetLastWin32Error() : 0);
}
catch (ObjectDisposedException)
{
socketError = SocketError.NotSocket;
}
if (socketError != SocketError.WouldBlock)
{
if (socketError == SocketError.Success)
{
asyncResult.Result = this.CreateAcceptSocket(safeCloseSocket, this.m_RightEndPoint.Create(socketAddress), false);
}
else
{
asyncResult.ErrorCode = (int)socketError;
}
this.InternalSetBlocking(true);
flag = true;
}
else
{
acceptQueue.Enqueue(asyncResult);
if (!this.SetAsyncEventSelect(AsyncEventBits.FdAccept))
{
acceptQueue.Dequeue();
throw new ObjectDisposedException(base.GetType().FullName);
}
}
}
else
{
acceptQueue.Enqueue(asyncResult);
}
}
finally
{
if (flag2)
Monitor.Exit(this);
}
if (!flag)
return;
if (socketError == SocketError.Success)
{
asyncResult.InvokeCallback();
return;
}
SocketException ex = new SocketException(socketError);
this.UpdateStatusAfterSocketError(ex);
throw ex;
}