Send data to form during intense method.

W

Wade

Hi all,

I have a form in a VB.NET windows application that, when a button is
clicked, runs a pretty intense database process which can take up to ten
minutes to finish. While it's running, I would like to be able to send data
to the form so that the user knows the the application is still running.

In ASP.NET, I would run this method in a new thread, and then simply update
the form occasionally with data from the application. Is the approach in a
windows application similar? And help and/or pointers would be greatly
appreciated.

Thanks,

Wade
 
W

Wade

Not sure if this is the best way to do this, but here's what I did ...

1. Created a new thread. The thread invokes the intense method.
2. I start the thread. The method called by the thread periodically updates
some status labels on the form.
3. I also created a timer that runs every second.
4. The timer checks to see if the thread is still alive. If so, it keeps
the controls disabled and prevents the form from being closed. If it's not,
then I know it's completed and I can wrap things up.

That sound like the right way to do this?

Thanks!
 
S

SharpCoderMP

Wade said:
Not sure if this is the best way to do this, but here's what I did ...

1. Created a new thread. The thread invokes the intense method.
2. I start the thread. The method called by the thread periodically updates
some status labels on the form.
3. I also created a timer that runs every second.
4. The timer checks to see if the thread is still alive. If so, it keeps
the controls disabled and prevents the form from being closed. If it's not,
then I know it's completed and I can wrap things up.
you dont need timer. your form can be enabled or disabled by a thread.
bur i wouldn't do that - it's because it would be nice to allow the user
co cancel this 10minute job. you should at least put a "cancel" button
somwhere that stops your thread and lets the user to take over control.
 

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