Vb Net Update Progress Bar Backgroundworker Thread Up

Re: Progress bar with backgroundworker. In this scenario, I have used UpdatePanel to wrap the bit I need to update and then a separate thread as the worker. Simply in the button click event of the Do Task button, I start a thread and hand over the long running task to the thread execution. For more information please refer this article. I have the standard progress bar and worker thread scenario with progress of the worker thread being fed back to the main UI and displayed on the progress bar. I have a delegate and am using BeginInvoke. But the progress bar is not updating. Have you come across the BackgroundWorker class yet? (new to Framework 2.0, IIRC). I don't recognise what your code is doing when it calls invoke tho, it should invoke the progress bar to increment, etc. The easy solution is to use the BackgroundWorker class, which can then be told to generate an event on the main UI thread to set the progress, or to report success.

-->

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Overloads

ReportProgress(Int32)

Raises the ProgressChanged event.

ReportProgress(Int32, Object)

Raises the ProgressChanged event.

Parameters

percentProgress
Int32

The percentage, from 0 to 100, of the background operation that is complete.

Exceptions

The WorkerReportsProgress property is set to false.

Examples

The following code example demonstrates the use of the ReportProgress method to report the progress of an asynchronous operation to the user. This code example is part of a larger example provided for the BackgroundWorker class.

Remarks

If you need the background operation to report on its progress, you can call the ReportProgress method to raise the ProgressChanged event. The WorkerReportsProgress property value must be true, or ReportProgress will throw an InvalidOperationException.

It is up to you to implement a meaningful way of measuring your background operation's progress as a percentage of the total task completed.

The call to the ReportProgress method is asynchronous and returns immediately. The ProgressChanged event handler executes on the thread that created the BackgroundWorker.

See also

Applies to

Parameters

percentProgress
Int32

The percentage, from 0 to 100, of the background operation that is complete.

userState
Object

A unique Object indicating the user state. Returned as the UserState property of the ProgressChangedEventArgs.

Exceptions

The WorkerReportsProgress property is set to false.

Examples

The following code example demonstrates the use of the ReportProgress method to report the progress of an asynchronous operation to the user. This code example is part of a larger example provided for the ToolStripProgressBar class.

Remarks

If you need the background operation to report on its progress, you can call the ReportProgress method to raise the ProgressChanged event. The WorkerReportsProgress property value must true, or ReportProgress will throw an InvalidOperationException.

It is up to you to implement a meaningful way of measuring your background operation's progress as a percentage of the total task completed.

See also

Applies to

Updating a progress bar

Updating a progress bar

I've searched everywhere for an answer to my problem. Everything I have found refers to something totally different than what I'm trying to do. I'm going to try writing up my problem here and maybe someone can give me a good solution.
1. I have a windows application with many winform objects to handle printing each with a progress bar and label on it. The winform is written in vb.net. My desktop application, which is written in vb.net, has many forms that generate reports. They all have the same basic premise of having report criteria controls as well as a progress bar and label.
2. I create a report that calls a method in a dll. The dll uses the PrintDocument class to create the actual report. That code is written in C#.
3. I have a special class that is located in the printing dll that is accessible from the desktop application. Among the things in that class are places for the progressbar and label.
4. During the printing of the report, I update the progress bar once per each loop through the data set.
The problem is I can't make the changes of the progressbar update to be seen in real time. It seems that the only time it does visually change is if I have to leave the print handler as I go from page to page. That tells me that this code isn't processing in real time. In fact, if I set a breakpoint right at the end of the updateProgressBar() and run the app, the progressbar does update. Of course, I have to keep hitting F5 to advance. So I need to find a way to make it happen during the print loop. I believe that is where the backgroundworker stuff comes in. However, I have no idea how to make that kind of code, so could use some serious help.
Here are some code snippets:
oPD = new xxxPRINTING.pdCommon(); // special object that contains many printing parameters and functions...
// including:
public void updateProgressBar ( ProgressBar pBar, System.Windows.Forms.Label lblCaption, int numRecs, int numCurrentRec )
{
if ( pBar != null )
{
// pBar.Increment (1);
pBar.PerformStep ();
pBar.Update (); // things to do to try to force the updated progressbar show...
pBar.Refresh ();
if ( lblCaption != null ) lblCaption.Text = String.Format ( 'Printing record {0} of {1}', numCurrentRec.ToString(), numRecs.ToString() );
System.Windows.Forms.Application.DoEvents();

Vb Net Update Progress Bar Backgroundworker Thread Update


} // <--- if I set a breakpoint here, then the progressbar updates with show. If I don't break here, the displayed progressbar is haphazard at best.
}
Print handler setup:
pD.PrintPage += new PrintPageEventHandler ( pDPrintReport );
pD.Print();
pD.PrintPage -= new PrintPageEventHandler ( pDPrintReport );
Printing loop. This code is found in the print event handler 'pDPrintReport' setup above:
for ( ; currentMember < numRecs; currentMember++ )
{
oPD.updateProgressBar ( localPrinterSettings.pBar, localPrinterSettings.lblCaption, numRecs, currentMember + 1 );
.
.
.
yPos += oPD.lineHeight;
if (yPos >= BottomOfPage)
break;Bar
}
// When I get here, it means that x number of records have peen printed and the veretical position has gone base the logical end-of-page.
// The progressbar DOES update when I get here...
Progress bar html if (currentMember >= numRecs )
{
e.HasMorePages = false;
}

Vb Net Update Progress Bar Backgroundworker Thread Up Official Site


else

Vb Net Update Progress Bar Backgroundworker Thread Up Free

{

Vb Net Update Progress Bar Backgroundworker Thread Up Online


currentMember++;
}
Thanks in advance,

Vb Net Update Progress Bar Backgroundworker Thread Upgrade

Jerry

Jerry Scannell