Scenario
I have a C# windows forms application that has a number of processes. These processes run on separate threads and all communicate back to the Main Form class with updates to a log window and a progress bar. I'm using the following code below, which up until now has worked fine, however, I have a few questions.
Code
delegate void SetTextCallback(string mxID, string text);
public void UpdateLog(string mxID, string text)
{
if (txtOutput.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(UpdateLog);
this.BeginInvoke(d, new object[] { mxID, text });
}
else
{
UpdateProgressBar(text);
}
}
Question
Will, calling the above code about 10 times a second, repeatedly, give me errors, exceptions or generally issues?.....Or more to the point, should it give me any of these problems?
Occasionally I get OutofMemory Exceptions and the program always seems to crash around this bit of code......