C# Screen not Refreshing during long process

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a Simple Windows Form which I placed a button and when the button is
pressed it proceses data into a database and I update the task bar for each
record.
The task bar would show processing 1 of 200 and so on...

The problem is if I click anyware on my form during this process it locks
and I cant do anything with that form.( my process keeps running but the form
stops updateing)
Now if I dont touch the form. its happy and my task bar updates ok.

How can I keep this from happening?
I was told to use a Thread but im not sure how to this.
Can I do someing like
Thread.Start();
My process runs...
Thread.stop();

Any Ideas or can I use something else?
 
On simple way is to do it asynchronously and a separate thread is one way.
Another easy way is to create a delegate that matches the signature of the
function you want to call. Then, delcare in instance of the delegate, and
use IAsyncResult ar = delegateName.BeginInvoke();//passing in null for the
addiotional parameters since you probably don't need a callback.
http://www.knowdotnet.com/articles/reponsiveui.html
 
Any Ideas or can I use something else?

I presume your processing occurs in a loop. The quickest, "low tech"
method of resolving your problem is to add a call to Application.DoEvents
to your loop.

This may suit your needs.

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
 
Thanks!!! That did the job.
Craig

Chris Dunaway" <"dunawayc[[at]_lunchmeat said:
Any Ideas or can I use something else?

I presume your processing occurs in a loop. The quickest, "low tech"
method of resolving your problem is to add a call to Application.DoEvents
to your loop.

This may suit your needs.

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
 
Back
Top