Re: MessageBox.Show and program behaviour
- From: "Nuno Magalhaes" <nunommagalhaes@xxxxxxxxxxx>
- Date: 15 Mar 2006 05:26:31 -0800
I don't think so. I always coded with threads and a sleep sets the
process into the queue process but a .DoEvents get's always called
whenever the process gets back in action.
By the way, I don't think I'm getting the error now, even without the
MessageBox.Show.
Mehdi wrote:
On 14 Mar 2006 13:43:01 -0800, Nuno Magalhaes wrote:
Why does the MessageBox.Show function in the thread below changes the
program behaviour, in other words, the APListView becomes filled with
values with a call to RefreshAPListView. Without the MessageBox.Show
function, in my laptop, the code doesn't get past the inner loop where
there is a Thread.Sleep(10).
Your code is just an infinite loop where you fill your APListView, then
sleep then fill your APListView again, then sleep... This means that
without that call to MessageBox.Show, the UI thread (in which you are
executing your loop i suppose) never gets a chance to process the pending
(painting) messages in its message queue. Therefore, even though your
APListView is effecively filled, it never gets painted because you are not
letting it time to paint itslef.
When you call MessageBox.Show, the UI thread sits there doing nothing until
your click OK to close the MessageBox, which lets it time to process its
message queue messages and to paint your APListView. If you want to force
the UI thread to process all pending messages in the message queue (and
therefore force it to paint your APListView), call Application.DoEvents().
But it doesn't seem a good idea to me to put the UI thread to sleep anyway
as whenever the UI thread is sleeping, your whole UI is frozen, preventing
the user from moving, resizing or using it.
.
- References:
- MessageBox.Show and program behaviour
- From: Nuno Magalhaes
- Re: MessageBox.Show and program behaviour
- From: Mehdi
- MessageBox.Show and program behaviour
- Prev by Date: Re: Windows Service Installer using Sockets
- Next by Date: Re: Reading keys from HKEY_CURRENT_USER from an impersonated Web Service
- Previous by thread: Re: MessageBox.Show and program behaviour
- Next by thread: How to use MsgBox in C#
- Index(es):
Relevant Pages
|
Loading