[OT] WinForms Windows Message Queue

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?
 
W

Willy Denoyette [MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top