G
Guest
I am writing a VB.NET application that has a Splash screen.
..NET has autogenerated MyApplication Class.
In that class OnCreateSplashScreen calls a shared property to get the Splash
screen.
In this shared property I instantiate the splash screen object.
On this Splash screen I have a DevExpress MarqueeProgressBarControl or just
in short a progress bar control.
When I start up my application I get an exception: "Cross-thread operation
not valid"
When I debug this I notice something strange
1) .NET Calls OnCreateSplashScreen and in turn my shared property, that
instantiates the splash screen, on one thread.
2) .NET then shows the splash screen on a different thread!
I tried to show my SplashScreen form as a regular form (not as a splash
screen) and it worked fine. So my conclution is:
The progress bar I am using is obviously creating a timer that is associated
with a different thread than the progress control it self because it is
instantiated with one thread and shown with another. This timer is then
sending OnTimer to the progress bar and I get the exception.
So my questions is:
Why does .NET use two threads to Create and Activate a Splash screen?
I would think a form object should be instantiated and shown on the same
thread so I am surpriced that the .NET framework (or the VB framework) is
doing it this way.
Any suggestions how I can fix this? (removing the progress bar isn't an
option and turning off CheckForIllegalCrossThreadCalls isn't either)
..NET has autogenerated MyApplication Class.
In that class OnCreateSplashScreen calls a shared property to get the Splash
screen.
In this shared property I instantiate the splash screen object.
On this Splash screen I have a DevExpress MarqueeProgressBarControl or just
in short a progress bar control.
When I start up my application I get an exception: "Cross-thread operation
not valid"
When I debug this I notice something strange
1) .NET Calls OnCreateSplashScreen and in turn my shared property, that
instantiates the splash screen, on one thread.
2) .NET then shows the splash screen on a different thread!
I tried to show my SplashScreen form as a regular form (not as a splash
screen) and it worked fine. So my conclution is:
The progress bar I am using is obviously creating a timer that is associated
with a different thread than the progress control it self because it is
instantiated with one thread and shown with another. This timer is then
sending OnTimer to the progress bar and I get the exception.
So my questions is:
Why does .NET use two threads to Create and Activate a Splash screen?
I would think a form object should be instantiated and shown on the same
thread so I am surpriced that the .NET framework (or the VB framework) is
doing it this way.
Any suggestions how I can fix this? (removing the progress bar isn't an
option and turning off CheckForIllegalCrossThreadCalls isn't either)