I have a Windows Form that calls a number of methods in 2 separate classes in a single dll.
In the Form I want to display status updates i.e. display in label how the query is progressing.
How do I track the status of methods of 2 different classes in dll?
Thanks!
Below is sample dll code…
public class ClassA
{
private string ProgressStatus
private void SetStatusText(string currentStatus)
{
progressStatus = currentStatus;
}
public void ReportRequest()
{
SetStatusText("Begin Process..."); // update status
SetStatusText("Getting Dates..."); // update status
// get dates
DatesClass myDates = new DatesClass()
datesOK = myDates.GetDates();
if (datesOK)
{
SetStatusText("Running Request...");
RunFinalRequest();
}
}
}
public internal class ClassB
{
private string ProgressStatus
private void SetStatusText(string currentStatus)
{
progressStatus = currentStatus;
}
public string GetDates()
{
SetStatusText("Loading Dates..."); // update status
LoadDates();
return // return sql query value
}
private void LoadDates()
{
// sql query...
SetStatusText("Run Query...");
}
}
It sounds like you want a BackgroundWorker. You’d create two background worker classes and have them run your methods. You can then use the
ProgressChangedevent to report progress back to your original thread.