开发者

Handle Exceptions from Thread in Global Exception Handler?

I have a main application with a global exception handler installed. Now, for some specific exceptions being raised within another thread I want the global exception handler to be invoked. But it does only handle exceptions from the main thread. I also tried the following from within the thread but it does not work either:

RunInMainThread (procedure
                 begin
                 rai开发者_JS百科se EExceptionFromWithinThread.Create;
                 end);

where RunInMainThread just executes the anonymous method given as a parameter in the context of the main thread.

Why doesn't this work? What's the proper way to handle such a situation?


How about this: send a message to the main thread which exception should be raised.


I handled the exception in the thread, saving the message as a common string variable. When the status of the thread changed, I checked the variable in the main thread. Makes for very readable code.


I do this in my framework if you are interested (http://www.csinnovations.com/framework_overview.htm).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜