DoEvents for a specific thread?

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
 
J

Jon Skeet [C# MVP]

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.
 
C

Carl

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
 
J

Jon Skeet [C# MVP]

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.
 
C

Carl

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
 

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