[OT] WinForms Windows Message Queue

  • Thread starter Thread starter Cool Guy
  • Start date Start date
C

Cool Guy

It's possible to cause a WinForm window's message queue to process messages
after it's processed WM_CLOSE, by using Invoke/BeginInvoke in a worker
thread (meaning that complex work-arounds are required to make code that
calls Invoke/BeginInvoke in a background thread thread-safe -- and which
apparently no-one on these groups entirely understands).

Is this a bug or by design?
 
Cool Guy said:
It's possible to cause a WinForm window's message queue to process
messages
after it's processed WM_CLOSE, by using Invoke/BeginInvoke in a worker
thread (meaning that complex work-arounds are required to make code that
calls Invoke/BeginInvoke in a background thread thread-safe -- and which
apparently no-one on these groups entirely understands).

Is this a bug or by design?

The thread's message loop isn't terminated when receiving a WM_CLOSE
message, it's only terminated when having retrieved a WM_QUIT message. There
is only one message loop per (UI) thread, but you can have multiple windows
served by the same thread, it's not because you close one windows that the
other windows should not get served any longer.

Willy.
 
Back
Top