Form Refresh During extensive process
Hi,
I need to refresh a winform (vb.net 2005) during an extensive process. The process is a DTS package execution (the process takes more than 5 minutes). I need to show to the user in a listbox the failure or success of every steps in the package during their execution. The form seems to frozen and even i use a timer to refresh it, it doesnt work. I tried the Application.DoEvents() too...but nothing seems to work.
any idea? sample code?
Thanks
mcrisf
[486 byte] By [
mcrisf] at [2007-12-28]
application.doevents is bad practice - can cause unpredicatable results at times. The best thing to do in such a situation, when a process is time consuming is to use Threading. Threading will make your app respond and the way it works is that in any app you have 1 main thread (also referred to as UI Thread) - if there is a process running on this that takes time then it will cause the UI to appear to be hung but its not. So running another thread to do the lengthy operation will make your UI, main thread, "free" from hanging.
take a look at this:
http://msdn2.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx
http://msdn2.microsoft.com/en-us/library/8xs8549b.aspx
I hope this helps