|
I converted the souce to 2.0 and when I press the execute button I get the following error:
System.InvalidOperationException was unhandled Message="Cross-thread operation not valid: Control 'tLog' accessed from a thread other than the thread it was created on." Source="System.Windows.Forms" StackTrace: at System.Windows.Forms.Control.get_Handle() at System.Windows.Forms.Control.set_WindowText(String value) at System.Windows.Forms.TextBoxBase.set_WindowText(String value) at System.Windows.Forms.Control.set_Text(String value) at System.Windows.Forms.TextBoxBase.set_Text(String value) at System.Windows.Forms.TextBox.set_Text(String value) at _4XLab.NET.Framework.ClearLog() in C:\Documents and Settings\randyd\My Documents\Visual Studio 2005\4xlab\4XLab[1].NET_5_2415\4XBase.DLL\Framework.cs:line 231 at _4XLab.NET.SystemTester.Execute() in C:\Documents and Settings\randyd\My Documents\Visual Studio 2005\4xlab\4XLab[1].NET_5_2415\4XBase.DLL\SystemTester.cs:line 54 at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()
I looked in the related help topic labeled:
How to: Make Thread-Safe Calls to Windows Forms Controls
I found a couple interesting things:
This exception occurs reliably during debugging and, under some circumstances, at run time. You are strongly advised to fix this problem when you see it. You might see this exception when you debug applications that you wrote with the .NET Framework prior to .NET Framework version 2.0.
Note |
|
You can disable this exception by setting the value of the CheckForIllegalCrossThreadCalls property to false. This causes your control to run the same way as it would run under Visual Studio 2003. |
I added the following line of code to LabGUI() and the problem went away however I think this is only a temporary fix. I am not sure what kind of strange behavior might occur from this threading issue.
Control .CheckForIllegalCrossThreadCalls = false;
Thanks
Randy
|