By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,722 Members | 1,251 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,722 IT Pros & Developers. It's quick & easy.

my program locks up on DB queries....

P: n/a
hey, I run long queries. like once that take my program about 3 minutes
straight to complete.. like I grab over 100,000 rows, and loop throguh each
row to update a certain value. etc..

the program freezes when all this calculation is going on, so I thought I'd
put a progress bar. I even made it on a separate thread and used the callback
/ delegate stuff to make it show.

so here's how the method goes:
private void btnDoDatabasestuff_Click(object sender, EventArgs e)
{
Thread thProgbar = new Thread(new ParameterizedThreadStart(ShowProgBar));
thProgbar.Start("show");

//Lots of code here to do stuff

Thread thProgbar = new Thread(new ParameterizedThreadStart(ShowProgBar));
thProgbar.Start("hide");
}

the problem is that it STILL locks up. the only difference this time is it
locks up with a progress bar on the screen. it's an animated progress bar and
it still stops moving.

is there any other stuff I should be doing?

thanks.,
Sep 16 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Sep 16, 3:53*pm, Rogelio <Roge...@discussions.microsoft.comwrote:
hey, I run long queries. like once that take my program about 3 minutes
straight to complete.. like I grab over 100,000 rows, and loop throguh each
row to update a certain value. etc..

the program freezes when all this calculation is going on, so I thought I'd
put a progress bar. I even made it on a separate thread and used the callback
/ delegate stuff to make it show.

so here's how the method goes:

private void btnDoDatabasestuff_Click(object sender, EventArgs e)
{
Thread thProgbar = new Thread(new ParameterizedThreadStart(ShowProgBar));
thProgbar.Start("show");

//Lots of code here to do stuff

Thread thProgbar = new Thread(new ParameterizedThreadStart(ShowProgBar));
thProgbar.Start("hide");

}

the problem is that it STILL locks up. the only difference this time is it
locks up with a progress bar on the screen. it's an animated progress barand
it still stops moving.

is there any other stuff I should be doing?
It sounds like you're still doing the database stuff in the UI thread,
which is the problem. Have a look at BackgroundWorker, which is
designed for this kind of situation.

Jon
Sep 16 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.