Currently I have a background thread whose doWork calls a function similar to below.
private void ThreadForAnalyzingReqFile_DoWork(object sender, DoWorkEventArgs e)
{
AnotherClass.AVeryLongTimedFunction();
}
Now, the code shall wait until AVeryLongTimedFunction() in AnotherClass finishes (that may take about 1-2 minutes) While this happens, how do I know exactly what’s happening? Is there any way I can be notified that function (in another class) finishes?
This thread is in my MainWindow class of WPF. I am using Visual Studio 2010.
There are many ways to do this. Two easy options:
(1) Create an event in your UI class such as
UpdateProgress, and notify that event at meaningful intervalsExample:
And in “AnotherClass”
(2) Create a progress percentage field on
AnotherClass. Occasionally interrogate this in your UI on a timer.