ClientStream.BeginRead(ReadBuffer, 0, ReadBuffer.Length, new AsyncCallback(ReceiveData), ClientStream);
private void ReceiveData(IAsyncResult asy)
{
if(true)
{
throw new Exception();
}
ClientStream.BeginRead(ReadBuffer, 0, ReadBuffer.Length, new AsyncCallback(ReceiveData), ClientStream);
}
我想在收到某一数据的时候抛出一个异常,通过对异常的捕捉进行相关的操作.
应该在哪里才能捕捉到这个异常呢?下面是e.StackTrace的内容,看不懂.
at Traffic_World.ControlTcpClient.ReceiveData(IAsyncResult asy) in E:\Development\Traffic World\开发\ControlPC\ControlPC\ControlTcpClient.cs:line 86
at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
at System.Net.ContextAwareResult.CompleteCallback(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Net.ContextAwareResult.Complete(IntPtr userToken)
at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
at System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)