C# Programming
02-09-2013, 03:50 AM
I have recently started to multithread my program and everything seems to work fine with the exception of a form I use to track the progress of data being transfered.
The Progress form is on the main thread, I send data to it as my program is processing it. The problem is that is does not appear on the form, I have used various methods to Invoke the thread but it just goes into a loop and never stops or just goes into oblivian. Some of the methods are as follows or similar:
public void UpdateStartTime(String text) { if (textBoxStartTime.InvokeRequired) { UpdateStartTimeCallback updateStartTimeCallback = new UpdateStartTimeCallback(UpdateStartTime); Invoke(updateStartTimeCallback, new object[] { Text }); } else { textBoxStartTime.Text = text; } } and public void UpdateStartTime(TextBox textBox, String text) { if (textBoxStartTime.InvokeRequired) { textBoxStartTime.Invoke(new Action(UpdateStartTime), new object[] { textBox, text }); } else { textBoxStartTime.Text = text; } }
I also tried a delegate but it just does not see the other thread, I have verified the thread numbers are different and they're being used, it just doesn't make the connection.
Any ideas or suggestions will be greatly appreciated, thanks in advance.
Michael
The Progress form is on the main thread, I send data to it as my program is processing it. The problem is that is does not appear on the form, I have used various methods to Invoke the thread but it just goes into a loop and never stops or just goes into oblivian. Some of the methods are as follows or similar:
public void UpdateStartTime(String text) { if (textBoxStartTime.InvokeRequired) { UpdateStartTimeCallback updateStartTimeCallback = new UpdateStartTimeCallback(UpdateStartTime); Invoke(updateStartTimeCallback, new object[] { Text }); } else { textBoxStartTime.Text = text; } } and public void UpdateStartTime(TextBox textBox, String text) { if (textBoxStartTime.InvokeRequired) { textBoxStartTime.Invoke(new Action(UpdateStartTime), new object[] { textBox, text }); } else { textBoxStartTime.Text = text; } }
I also tried a delegate but it just does not see the other thread, I have verified the thread numbers are different and they're being used, it just doesn't make the connection.
Any ideas or suggestions will be greatly appreciated, thanks in advance.
Michael