Refreshing Form on Process

1

11Oppidan

Hello,

I have a windows application written in VB .NET which pulls a lot of data
from different databases into one source. This often takes a long time and
therefore I track the progress using a progress bar and a status bar.

When the program is running and I use another application the form turns
white and doesn't refresh itself until the process is complete. Could anyone
advice me/provide a VB example of the best way to keep a windows form
refreshed when running, but still restrict the user from setting off another
process?

Many thanks for your advice.
 
G

gyurisc

You should probably use a new thread to complete the operation. There is a
component called backgroundworker what is a component in whidbey and can be
used for this purpose.

If you do not want to do multithreading then you should try to call the
Application.DoEvents() method while you are waiting for the data to arrive.

Cris
 
1

11Oppidan

Application.DoEvents works great but lets the user have of the cursor back
from my WaitCursor, enabling them to restart the process. How do I lock up
the form when using Application.DoEvents whilst it's running.

Many thanks for your assistance - it's much appreciated.
 
J

Jason Newell

11Oppidan,
I haven't tried it but what about "this.Enabled = false" where "this"
refers to your main form. Then "this.Enabled = true" when you're done.

Jason Newell, MCAD
Software Engineer
 
J

Jeffrey Tan[MSFT]

Hi 11Oppidan,

Based on my understanding, your current concern is how to prevent the user
from re-starting the background processing(database querying) when the
processing is going. If I misunderstand you, please feel free to tell me.
Thanks

I think Jason has provided you a way to disable the entire form(Just set
Form.Enabled=false), which will diable any user interaction function of the
form. But normally, I think it is better for the user can still get the UI
interaction, we may just disable the button's function that may re-start
the background processing(Just use this.button1.Enabled=false).

Additionally, I think using multithreading will give application user a
better interactive experience, which is easy to implement in .Net. You may
refer to the Chris Sells' article for a good idea, it uses a demo
application, which calculate the accurate value of PI in background thread,
and in UI thread, it uses a prograssbar to display the processing prograss:
"Safe, Simple Multithreading in Windows Forms, Part 1"
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnforms/htm
l/winforms06112002.asp

Hope this helps
========================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

Jeffrey Tan[MSFT]

Hi 11Oppidan,

Does my reply make sense to you? Do you still have any concern on this
issue? Please feel free to tell me. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

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