Eric Lilja wrote:
[...] Any messages are
displayed in an editbox. If a severe error occurs, an exception is
thrown. Will there be any problems if I catch these exceptions in the
main thread? [...]
Just thinking about that setup makes my head spin. Yes, I suspect
there'll be lots of problems if you do this. :-)
The very concept of "catching the exception in main" is absurd when
threads are involved: the whole point of exception catching and throwing
is that it is totally synchronous, and goes from callee to caller (to
its caller and so on, until your main()).
All of this only makes sense in the context of one thread. Implicit in
the catching of an exception is the idea that the exception was thrown
from _something you called from within that try block_.
Otherwise, you'd have a situation like:
/* parent: */
func() {
...
// spawn thread
return; //!!
}
main()
{
...
func();
...
some_other_random_stuff();
}
/* child: */
...
throw something;
...
Err, but the point from where the thread was created is no longer on the
stack, because control returned to the parent and then went on somewhere
else. So even if you attempted to do something bizarre like "hop stacks
to the parent thread's stack", you'd end up in some random stack frame
in the parent thread, like "some_other_random_stuff()", which won't be
expecting that exception and won't know what to do with it...
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/