开发者

How to catch exception from thread?

开发者 https://www.devze.com 2022-12-14 19:54 出处:网络
I am using 开发者_如何学Goa free .net telnet component (De.Mud.Telnet), which has several asynchronous methods you can call, and the component fires events when things happen.My problem is that the co

I am using 开发者_如何学Goa free .net telnet component (De.Mud.Telnet), which has several asynchronous methods you can call, and the component fires events when things happen. My problem is that the component is throwing an exception and I don't know how to catch it. There's no exception event, and the exception doesn't get thrown by my method call. I'm using this component from a service, and I don't know how to trap the exception.


Source code appears to be available here. Not sure of course, but it certainly matches your problem description. Whomever wrote this code was quite clueless about how exceptions work. The callbacks are the problem, when something goes wrong they throw an ApplicationException. Those exceptions are uncatchable, the callbacks are made on a threadpool thread.

This might have worked somewhat back in the .NET 1.x days, it would simply stop working properly instead of aborting your program. At least you're ahead, you now know it isn't working properly. Given that the code does very little and that the way it works is basically unfixable, I'd have to strongly recommend you just forget about using this.

Check out nsoftware.com for a company that sells a real library.


Check the latter part of this page, it is part of a good .NET threading guide that I refer to often for threading help.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号