G
Guest
Hi,
I have an application that seems to crash upon startup in isolated
situations (double clicking an associated file). I looked into it a little
bit and noticed it was getting to the point where it was closing a splash
screen that the problem occurred.
Example:
In the main form -
// close the splash screen
SplashForm.CloseForm();
In the splash form -
in splash constructor:
closeDelegate = new CloseDelegate(this.Close);
hideDelegate = new HideDelegate(this.Hide);
...
public static void CloseForm()
{
if (splash != null)
{
splash.Invoke(splash.closeDelegate, null);
Application.DoEvents();
splash = null;
thread = null;
}
}
public static HideForm()
{
splash.Invoke(splash.hideDelegate, null);
Application.DoEvents();
}
When closing the form, the splash.Invoke... line throws a NullReference
exception, but neither closeDelegate nor splash is null, and appear to be
instantiated properly.
I suspect there is some kind of odd timing/threading issue going on since
this only happens on Win2000 machines. To make things a little weirder, if I
hide the form first by calling this instead:
// hide the splash screen
SplashForm.HideForm();
SplashForm.CloseForm();
The splash form is closed, the program continues on, and there is no
problem. Any ideas on what the possible cause is here, and why it might be
different on Win2k compared to XP?
Jon Hiley
I have an application that seems to crash upon startup in isolated
situations (double clicking an associated file). I looked into it a little
bit and noticed it was getting to the point where it was closing a splash
screen that the problem occurred.
Example:
In the main form -
// close the splash screen
SplashForm.CloseForm();
In the splash form -
in splash constructor:
closeDelegate = new CloseDelegate(this.Close);
hideDelegate = new HideDelegate(this.Hide);
...
public static void CloseForm()
{
if (splash != null)
{
splash.Invoke(splash.closeDelegate, null);
Application.DoEvents();
splash = null;
thread = null;
}
}
public static HideForm()
{
splash.Invoke(splash.hideDelegate, null);
Application.DoEvents();
}
When closing the form, the splash.Invoke... line throws a NullReference
exception, but neither closeDelegate nor splash is null, and appear to be
instantiated properly.
I suspect there is some kind of odd timing/threading issue going on since
this only happens on Win2000 machines. To make things a little weirder, if I
hide the form first by calling this instead:
// hide the splash screen
SplashForm.HideForm();
SplashForm.CloseForm();
The splash form is closed, the program continues on, and there is no
problem. Any ideas on what the possible cause is here, and why it might be
different on Win2k compared to XP?
Jon Hiley