当前位置: 首页>>代码示例>>C#>>正文


C# LazyAsyncResult.InvokeCallback方法代码示例

本文整理汇总了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;
 }
开发者ID:REALTOBIZ,项目名称:mono,代码行数:7,代码来源:_SingleItemRequestCache.cs

示例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;
		}
开发者ID:BjkGkh,项目名称:R106,代码行数:77,代码来源:Socket.cs


注:本文中的LazyAsyncResult.InvokeCallback方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。