Follow in Twitter & Facebook


Like in Facebook

Powered By Blogger Widgets

Free Download

FREE Tools


Thursday, April 26, 2012

This BackgroundWorker states that it doesn't report progress.Modify WorkerReportsProgress to state that it does report progress.









Introduction:
Here in this article, we will discuss about one InvalidOperationException which i got while doing one windows application demo using one BackgroundWorker using Vb.net. That Exception was like "This BackgroundWorker states that it doesn't report progress. Modify WorkerReportsProgress to state that it does report progress.".

Description:
I got this Exception while doing one demo in visual studio 2010 for one Backgroundworker in vb.net. I got the error like "This BackgroundWorker states that it doesn't report progress. Modify WorkerReportsProgress to state that it does report progress."

This is nothing but one InvalidOperationException.
At that time my code was like that only as belows

 Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
        For i As Integer = 0 To m_CountTo
            ' Has the background worker be told to stop?
            If BackgroundWorker1.CancellationPending Then
                ' Set Cancel to True
                e.Cancel = True
                Exit For
            End If
            System.Threading.Thread.Sleep(1000) ' Sleep for 1 Second
            ' Report The progress of the Background Worker.
            BackgroundWorker1.ReportProgress(CInt((i / m_CountTo) * 100))
        Next
    End Sub



I got the exception in the line    BackgroundWorker1.ReportProgress(CInt((i / m_CountTo) * 100)).
I am sharing the screenshot of that exception as below:


So now i searched for the solution , I got the solution, the solution is that you need to set
the property  of the Backgroundworker i.e WorkerReportsProgess to true.Previously it was false. so i am also sharing the screenshot of that solution as below..




0 on: "This BackgroundWorker states that it doesn't report progress.Modify WorkerReportsProgress to state that it does report progress."