BackgroundWorker.ReportProgress Method (Int32, Object)

Raises the ProgressChanged event.

Namespace:  System.ComponentModel
Assembly:  System (in System.dll)

member ReportProgress : 
        percentProgress:int * 
        userState:Object -> unit

Parameters

percentProgress
Type: System.Int32

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

userState
Type: System.Object

The state object passed to RunWorkerAsync.

ExceptionCondition
InvalidOperationException

The WorkerReportsProgress property is set to false.

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.

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.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft