I am using a background worker and reporting the progress to a progress bar.
In BackgroundWorker DoWork
Event I am calling few methods on completion of each method. I am literally updating the progress value which works fine.
But when I call an async method in my DoWork, after call ends, I am updating the progress value with my desired value - but it throws to me an exception that says:
"Operation has already been completed" this occurs only when i call an "async method".
This is my code:
LoginBackgroundThreadReport(20, "Requesting Token");
long _StatusCode = await RequestNewToken();
LoginBackgroundThreadReport(30, "Configuring Device");
//LoginBackgroundThreadReport method
private void LoginBackgroundThreadReport(int pValue, string pMessage, long pStatusCode = 0)
{
object[] _arr = new object[2];
_arr[0] = pMessage;
_arr[1] = pStatusCode;
LoginBackgroundWorker.ReportProgress(pValue, _arr);
}
Here "Requesting Token" is displayed but the "configure device" fails, as I am updating value 30 after I call async method that is updating my progress value automatically to 100.