J
Jeroen
We converted our decently large (13 projects, compiled about 12 mb)
VStudio 2003/.Net1.1 project to VStudio 2005/.Net2. My two colleagues
have no problem starting the new solution, but I get an exception
thrown at me. I only get the exception if I run in debug mode, in
release mode all works fine. The exception thrown somewhere along
startup sequence is:
The following snippet shows where the exception is thrown:
----------------------------------------------------------------------
public class PleaseWait : System.Windows.Forms.Form
{
private static PleaseWait fWindow = null;
public static void ShowWindow(string message)
{
if(fWindow == null)
{
fWindow = new PleaseWait();
fWindow.Owner = System.Windows.Forms.Form.ActiveForm;
}
// long i = 0;
// while (i++ < 40000000) ;
fWindow.Show();
// ...etcetera
}
}
--------------------------------------------------------------------------
The ShowWindow method is called from somewhere else in the application
during startup. If I uncomment the counter and let it wait for a
while, no exception is thrown. No exception is thrown either if I
break the code just before the Show instruction and wait a few secs.
I have found articles on this but the problem is I cannot distill a
resolution for the mystery the above poses to me. Can anyone provide
an explanation of what's happening with the above info?
VStudio 2003/.Net1.1 project to VStudio 2005/.Net2. My two colleagues
have no problem starting the new solution, but I get an exception
thrown at me. I only get the exception if I run in debug mode, in
release mode all works fine. The exception thrown somewhere along
startup sequence is:
[ InvalidOperationException ]
Cross-thread operation not valid: Control '' accessed from a thread other than the thread it was
created on.
The following snippet shows where the exception is thrown:
----------------------------------------------------------------------
public class PleaseWait : System.Windows.Forms.Form
{
private static PleaseWait fWindow = null;
public static void ShowWindow(string message)
{
if(fWindow == null)
{
fWindow = new PleaseWait();
fWindow.Owner = System.Windows.Forms.Form.ActiveForm;
}
// long i = 0;
// while (i++ < 40000000) ;
fWindow.Show();
// ...etcetera
}
}
--------------------------------------------------------------------------
The ShowWindow method is called from somewhere else in the application
during startup. If I uncomment the counter and let it wait for a
while, no exception is thrown. No exception is thrown either if I
break the code just before the Show instruction and wait a few secs.
I have found articles on this but the problem is I cannot distill a
resolution for the mystery the above poses to me. Can anyone provide
an explanation of what's happening with the above info?