DoEvents vs. Threading

G

Greg Allen

I have a .NET windows application which imports large amounts of data.
While
the import is happening, I have a status/progress bar on the bottom of the
form
that is being updated as the data is imported. No other interaction with
the
form can occur while this is going on - I just want the status/progress
updated.

However, as the processing is occuring, other windows events are not being
handled. I have been trying to figure out how to fix this, but nothing
seems to
work quite right.

If I put calls to Application.DoEvents in the code, the form is repainted,
etc.
as necessary. But that also seems to change things enough so that the user
can then interact with the form while the processing is going on. And for
some reason is changes my cursor from the busy cursor I am using back to
the normal "pointer" cursor.

Threading would probably work. But there is the problem of communicating
via the thread and UI to update the status. And also preventing any
interaction
with the form while processing is occuring.

You'd think there would be a standard "progress dialog" that would handle
all this correctly for me. But I haven't found it. Is there one?

What do people suggest? This seems like a common problem...

Thanks,

-- Greg Allen
 
K

Ken Tucker [MVP]

Hi,

http://msdn.microsoft.com/msdnmag/issues/04/05/BasicInstincts/default.aspx

Ken
-------------------
I have a .NET windows application which imports large amounts of data.
While
the import is happening, I have a status/progress bar on the bottom of the
form
that is being updated as the data is imported. No other interaction with
the
form can occur while this is going on - I just want the status/progress
updated.

However, as the processing is occuring, other windows events are not being
handled. I have been trying to figure out how to fix this, but nothing
seems to
work quite right.

If I put calls to Application.DoEvents in the code, the form is repainted,
etc.
as necessary. But that also seems to change things enough so that the user
can then interact with the form while the processing is going on. And for
some reason is changes my cursor from the busy cursor I am using back to
the normal "pointer" cursor.

Threading would probably work. But there is the problem of communicating
via the thread and UI to update the status. And also preventing any
interaction
with the form while processing is occuring.

You'd think there would be a standard "progress dialog" that would handle
all this correctly for me. But I haven't found it. Is there one?

What do people suggest? This seems like a common problem...

Thanks,

-- Greg Allen
 

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