| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 792 人关注过本帖
标题:在异步收发中抛出的异常在哪里能捕捉到?
只看楼主 加入收藏
swc
Rank: 3Rank: 3
等 级:论坛游民
威 望:6
帖 子:394
专家分:83
注 册:2006-4-7
结帖率:100%
收藏
 问题点数:0 回复次数:1 
在异步收发中抛出的异常在哪里能捕捉到?

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)

搜索更多相关主题的帖子: 收发 异步 
2006-12-20 22:00
swc
Rank: 3Rank: 3
等 级:论坛游民
威 望:6
帖 子:394
专家分:83
注 册:2006-4-7
收藏
得分:0 

自顶一下,期待问题的解决!


实践、学习、再实践、再学习......
2006-12-21 14:12
快速回复:在异步收发中抛出的异常在哪里能捕捉到?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.029215 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved