[Gtk-sharp-list] Creating critical section for unhandled exception handler
Christopher David Howie
me at chrishowie.com
Sun May 23 20:57:46 EDT 2010
On 05/23/2010 05:16 PM, Styne wrote:
> If something is reentrant then it can be called again without
> waiting for the previous invocation. So if we assume that my
> UnhandledException event handler is reentrant (since it doesn't
> access global data etc.) then it can be executed concurrently.
What member of what class are you attaching your event handler to?
> Now the point that looses me completely... the thread never leaves my
> event handler so how can it reenter it? The thread calls
> Dialog.Run() which is meant to block. If this blocks then how can the
> same blocked thread reenter the event handler?
Run() blocks in that it does not return until the dialog is closed. But
it must call the GLib main loop again, because this loop is responsible
for dispatching GTK+ events. In other words, if it did not re-enter the
main loop, the dialog would not be able to respond to events. So this
is the possible execution path I see:
* GLib main loop.
** Unhandled exception handler, calls Dialog.Run().
*** Dialog.Run() sets up the dialog, calls main loop to process events.
**** GLib main loop.
***** Unhandled exception handler.
It sounds like you need a more sophisticated mechanism to handle the
case where exceptions may be thrown while the dialog is shown. You
might consider using a Queue<> to hold exceptions that have been thrown.
Additionally, you should be very careful to catch every possible
exception that might occur in your UnhandledException handler so as to
prevent an infinite loop.
If you correspond with me on a regular basis, please read this document:
PGP fingerprint: 2B7A B280 8B12 21CC 260A DF65 6FCE 505A CF83 38F5
This document should be read only by those persons to whom it is
addressed. If you have received this message it was obviously addressed
to you and therefore you can read it.
Additionally, by sending an email to ANY of my addresses you are
agreeing that I am, by definition, "the intended recipient," and that I
may do whatever I wish with the contents of any message you send me,
unless a pre-existing agreement prohibits me from so doing.
This overrides any disclaimer or statement of confidentiality that may
be included on your message.
More information about the Gtk-sharp-list