[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 361
  • Last Modified:

VB. Net app- UI threads/ background process help

Hi,

I was wondering if someone can help. I am creating an application and require a database extract to be done for the user as well as a status bar to move to inform the user of the progress made. The problem is that the screen locks up when this is started and the user is unable to do anything else. I have had a look at possibly using threads as well as something called background process which seems like this could work. The only problem is if i create a thread etc i need to pass a count between this and the user interface. Can someone recommend the best way to keep these in sync.

Thanks

Ross
0
ross13
Asked:
ross13
2 Solutions
 
Jeff CertainCommented:
You can use BackgroundWorker and report progress. Here's the MSDN sample. http://msdn.microsoft.com/en-us/library/ka89zff4.aspx
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
If you use the BackgroundWorker() control:
http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx

...then you simply call the ReportProgress() method from the DoWork() handler:
http://msdn.microsoft.com/en-us/library/a3zbdb1t.aspx

This will cause the ProgessChanged() event to fire.  It is safe to update the GUI from that event:
http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.progresschanged.aspx

*The WorkerReportsProgess() property must be set to true:
http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.workerreportsprogress.aspx
0
 
Jeff CertainCommented:
Wow... that's a much more description answer than mine. Well done Bob!
0
 
Éric MoreauSenior .Net ConsultantCommented:
instead of using threading for database access, you should use the asynchronous features built-in to ADO.Net: http://emoreau.com/Entries/Articles/2006/11/MARS-and-Asynchronous-ADONet.aspx
0
 
Mohamed AbowardaSoftware EngineerCommented:
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now