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

Re: DoEvents for a specific thread? by Jon

Jon
Mon Mar 03 04:54:10 CST 2008

Carl <ask@4it.com> wrote:
> 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.

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk

Re: DoEvents for a specific thread? by Carl

Carl
Mon Mar 03 05:30:38 CST 2008

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

"Jon Skeet [C# MVP]" <skeet@pobox.com> wrote in message
news:MPG.2235e92ba0c8d9aa23@msnews.microsoft.com...
> Carl <ask@4it.com> wrote:
>> 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.
>
> --
> Jon Skeet - <skeet@pobox.com>
> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
> World class .NET training in the UK: http://iterativetraining.co.uk


Re: DoEvents for a specific thread? by Jon

Jon
Mon Mar 03 05:44:33 CST 2008

Carl <ask@4it.com> wrote:
> 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.

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk

Re: DoEvents for a specific thread? by Carl

Carl
Mon Mar 03 08:25:17 CST 2008

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

"Jon Skeet [C# MVP]" <skeet@pobox.com> wrote in message
news:MPG.2235f4ffe48f2b3ca25@msnews.microsoft.com...
> Carl <ask@4it.com> wrote:
>> 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.
>
> --
> Jon Skeet - <skeet@pobox.com>
> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
> World class .NET training in the UK: http://iterativetraining.co.uk