[plt-scheme] Letting Windows close DrScheme

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Fri Jul 30 11:47:33 EDT 2004

At Wed, 28 Jul 2004 14:33:29 -0700 (PDT), Gordon Weakliem wrote:
> So I'm sure what's happening is that MrEd returns 0 to
> WM_QUERYENDSESSION and kills the shutdown.

Right.

> As far as saving unsaved files, it seems like a lot of apps will
> display a dialog to prompt for save, I don't think you can get around
> that, you can't make a reasonable save/nosave decision without
> asking.

This is essentially the problem. Within MrEd, you might have any number
of Scheme applications running, each in its own eventspace. The
individual applications have to consent to exiting. In principle,
that's not a problem (MrEd is willing to exit if all of the
applications are will), but there's an issue with the way that Windows
messages are dispatched internally.

If MrEd receives a WM_QUERYENDSESSION, it must not dispatch any further
messages until it has an answer. In fact, MrEd can't even switch Scheme
threads until it picks an answer. Disallowing thread switches is
obviously a problem if the answer depends on work done by different
applications within MrEd.

Possibly, this problem can be solved by setting up a separate Windows
thread whose only job is to handle WM_QUERYENDSESSION messages. MrEd
could then switch its own threads normally (in the original Windows
thread) while the separate Windows thread waits for an answer. I'll try
that sometime in the v299 branch.

Matthew



Posted on the users mailing list.