473,320 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

BackgroundWorker Question

I am testing backgroundWorker to update our installer with both messages
and with a progress bar. I am finding however that the text never gets
updated. Any ideas what I might be doing wrong? Code snipped for brevity.

Peter

private BackgroundWorker worker;
private void Install_Click(object sender, EventArgs e)
{
worker = new BackgroundWorker();
worker.RunWorkerCompleted += new
RunWorkerCompletedEventHandler(worker_WorkerComple ted);
worker.ProgressChanged += new
ProgressChangedEventHandler(worker_ProgressChanged );
worker.DoWork += new DoWorkEventHandler(worker_DoWork);
worker.WorkerReportsProgress = true;
worker.WorkerSupportsCancellation = true;
worker.RunWorkerAsync();
}

void worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
txtInfo.Text = e.ProgressPercentage.ToString();
}

void worker_DoWork(object sender, DoWorkEventArgs e)
{
BackgroundWorker bw = (BackgroundWorker)sender;
for (int i = 0; i < 1000000; i++)
{
bw.ReportProgress(i);
}
}

Mar 10 '08 #1
2 1789
Refrsh the textbox.

void worker_ProgressChanged(object sender, ProgressChangedEventArgs
e)
{
txtInfo.Text = e.ProgressPercentage.ToString();
txtInfo.Refresh();
}
"Peter Carlson" <peter@h_o_w_u_d_o_d_a_t.comwrote in message
news:ei*************@TK2MSFTNGP05.phx.gbl...
>I am testing backgroundWorker to update our installer with both messages
and with a progress bar. I am finding however that the text never gets
updated. Any ideas what I might be doing wrong? Code snipped for brevity.

Peter

private BackgroundWorker worker;
private void Install_Click(object sender, EventArgs e)
{
worker = new BackgroundWorker();
worker.RunWorkerCompleted += new
RunWorkerCompletedEventHandler(worker_WorkerComple ted);
worker.ProgressChanged += new
ProgressChangedEventHandler(worker_ProgressChanged );
worker.DoWork += new DoWorkEventHandler(worker_DoWork);
worker.WorkerReportsProgress = true;
worker.WorkerSupportsCancellation = true;
worker.RunWorkerAsync();
}

void worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
txtInfo.Text = e.ProgressPercentage.ToString();
}

void worker_DoWork(object sender, DoWorkEventArgs e)
{
BackgroundWorker bw = (BackgroundWorker)sender;
for (int i = 0; i < 1000000; i++)
{
bw.ReportProgress(i);
}
}
Mar 10 '08 #2
Thx.

Rene wrote:
Refrsh the textbox.

void worker_ProgressChanged(object sender,
ProgressChangedEventArgs e)
{
txtInfo.Text = e.ProgressPercentage.ToString();
txtInfo.Refresh();
}
"Peter Carlson" <peter@h_o_w_u_d_o_d_a_t.comwrote in message
news:ei*************@TK2MSFTNGP05.phx.gbl...
>I am testing backgroundWorker to update our installer with both
messages and with a progress bar. I am finding however that the text
never gets updated. Any ideas what I might be doing wrong? Code
snipped for brevity.

Peter

private BackgroundWorker worker;
private void Install_Click(object sender, EventArgs e)
{
worker = new BackgroundWorker();
worker.RunWorkerCompleted += new
RunWorkerCompletedEventHandler(worker_WorkerCompl eted);
worker.ProgressChanged += new
ProgressChangedEventHandler(worker_ProgressChange d);
worker.DoWork += new DoWorkEventHandler(worker_DoWork);
worker.WorkerReportsProgress = true;
worker.WorkerSupportsCancellation = true;
worker.RunWorkerAsync();
}

void worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
txtInfo.Text = e.ProgressPercentage.ToString();
}

void worker_DoWork(object sender, DoWorkEventArgs e)
{
BackgroundWorker bw = (BackgroundWorker)sender;
for (int i = 0; i < 1000000; i++)
{
bw.ReportProgress(i);
}
}
Mar 11 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: JHoletzeck | last post by:
Is it possible to set the stack size for the thread created by BackgroundWorker like in the API call _beginthread? If not is the stack size a default or the one I set for the whole application?...
3
by: Pro1712 | last post by:
Hi, this may be a stupid question: How can I can call the DoWork-function of a BackgroundWorker synchronous? Or in other words: How can I extend the BackgroundWorker class with a function...
0
by: Nicolas Zenou | last post by:
Hey everyone, I am new to .NET Framework programing and I have an important question. In fact, I need to launch many thread in my application. I assume to use backgroundWorker which are really...
5
by: Rob R. Ainscough | last post by:
I'm using a BackgroundWorker to perform a file download from an ftp site. Per good code design practices where I separate my UI code from my core logic code (in this case my Download file method in...
1
by: ditnooitlezen | last post by:
Hi, the (.NET 2.0) backgroundworker object has a DoWork method that operates in a background thread. When the DoWork method is finished the RunWorkerCompleted event is raised in the parent...
9
by: =?Utf-8?B?VE9NX1Bhc2FkZW5h?= | last post by:
Hello, In my ASP.Net app I'm launching a BackgroundWorker thread in my Page_Load function. In that thread I'm attempting to connect to a SQL server using this connection string "Initial...
9
by: RvGrah | last post by:
I'm completely new to using background threading, though I have downloaded and run through several samples and understood how they worked. My question is: I have an app whose primary form...
3
by: Coaster | last post by:
I want to create a "thread manager" class to manage an array of backgroundworkers. I'd like this thread manager class to live in a class library and I wasn't sure if it was possible to make the...
1
by: schnandr | last post by:
Hi, I have a user control which contains ListView. I copy all ListViewItems into a separate List<ListViewItemcalled unfilteredItems. I am using a BackgroundWorker to filter the ListView. When...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.