DoEvents for a specific thread?

  • Thread starter Thread starter Carl
  • Start date Start date
C

Carl

Hi,

I have a thread (not the main) in my app that draws GUI. It's a STA-thread,
and it seems OK. Though I would like to process its message queue, like

Application.DoEvents (for the main thread). It should have a message queue
since it draws GUI. How do I "do a DoEvents" for a specific thread?

regards

Carl
 
Carl said:
I have a thread (not the main) in my app that draws GUI. It's a STA-thread,
and it seems OK. Though I would like to process its message queue, like

Application.DoEvents (for the main thread). It should have a message queue
since it draws GUI.

It will have a message queue if you've made it have one. Are you
calling Application.Run on that thread?
How do I "do a DoEvents" for a specific thread?

Well, it would be best to avoid requiring DoEvents in the first place.
Why do you want to call it?

I believe if you call Application.DoEvents() on the other thread,
however, it will process that thread's message queue.
 
I'm calling myForm.ShowDialog (instead of Application.Run) which I think
also creates a message queue. I want to call it because I need to set
myForm.TopMost and/or BringToFront toghether with DoEvents, in each loop, to
make sure that the form always (or as much as possible at least) is visible
on top.

regards

Carl
 
Carl said:
I'm calling myForm.ShowDialog (instead of Application.Run) which I think
also creates a message queue. I want to call it because I need to set
myForm.TopMost and/or BringToFront toghether with DoEvents, in each loop, to
make sure that the form always (or as much as possible at least) is visible
on top.

It's still not clear to me where DoEvents comes in.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
 
I have solved it now atleast partly. Why I needed it was to make sure that
the TopMost message was consumed by the message pump in the thread.

regards

Carl
 
Back
Top