| 编程中国 | 业界新闻 | 技术文章 | 视频教程 | 下载频道 | 程序源码 | 个人空间 | 编程论坛
全能ASP/PHP/ASP.NET主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付买域名,送MP3、MP4
高端软件开发 = 年薪十万不是梦赛孚耐:软件保护加密专家身份认证令牌USB KEY买空间,免费送域名(厦门中资源)
共有 252 人关注过本帖
标题:在异步收发中抛出的异常在哪里能捕捉到?
收藏  订阅  推荐  打印 
swc
Rank: 3Rank: 3
等级:中级会员
威望:5
帖子:356
积分:3740
注册:2006-4-7
在异步收发中抛出的异常在哪里能捕捉到?

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
等级:中级会员
威望:5
帖子:356
积分:3740
注册:2006-4-7

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


实践、学习、再实践、再学习......
2006-12-21 14:12
关于我们 | 广告合作 | 编程中国 | 清除Cookies | Archiver | WAP | TOP

编程中国 版权所有,并保留所有权利。鲁ICP备08000592号
Powered by Discuz, Processed in 0.049739 second(s), 9 queries.
Copyright©2004-2008, BCCN.NET, All Rights Reserved