I have 2 forms, 1 which monitors my batch jobs in SQL Server Agent, and the other that throws up a new form to show the results of the last refresh (jobs that have failed since the last refresh). The second form is started by a background worker so the main [monitoring] form can keep refreshing at it's set intervals.
If the status form is still open when the next refresh runs [and finds errors], I want to be able to close the status form, then re-open it showing the previous errors, along with the new ones.
To determine if the form is still open, I have a "ShowingAlerts" boolean variable on the parent form that is set in the "DoWork" background worker method, and it gets set back to false in the "RunWorkerCompleted" method.
Since the status form is still showing, I want to just close it by calling my own method [in the status form] called "CloseResults" which really just calls the forms "Close" method.
When trying to access the status form's "CloseResults" method from the main form, it throws the cross-thread error. I have another program where I implemented the delegate (method???) and that works great, but not sure if it will work here. But since I'm not sending any variables to the status form, just trying to close it, I'm not sure how to implement the:
Can anyone give me some tips on this?
Thanks,
If the status form is still open when the next refresh runs [and finds errors], I want to be able to close the status form, then re-open it showing the previous errors, along with the new ones.
To determine if the form is still open, I have a "ShowingAlerts" boolean variable on the parent form that is set in the "DoWork" background worker method, and it gets set back to false in the "RunWorkerCompleted" method.
Since the status form is still showing, I want to just close it by calling my own method [in the status form] called "CloseResults" which really just calls the forms "Close" method.
When trying to access the status form's "CloseResults" method from the main form, it throws the cross-thread error. I have another program where I implemented the delegate (method???) and that works great, but not sure if it will work here. But since I'm not sending any variables to the status form, just trying to close it, I'm not sure how to implement the:
Code:
if (frmStatus.InvokeRequired)
{
{delegate} d = new {delegate}(??????);
this.Invoke(d, new object[] {?????});
}
Can anyone give me some tips on this?
Thanks,