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)

Re: .NET Splash Screen Thread Problem by Markus

Markus
Wed Oct 25 12:34:02 CDT 2006

> Any suggestions how I can fix this? (removing the progress bar isn't
> an option and turning off CheckForIllegalCrossThreadCalls isn't
> either)

Most probably you should take care of the update of the progress bar (I
am assuming, you are settings a new value of the progress bar).

The call "myProgressbar.Value = xyz" is maybe from another thread. So be
sure, you call it via myProgressBar.BeginInvoke(SomeMethod). And in this
method, you can set the new value of the progress bar.

hth
Markus

Re: .NET Splash Screen Thread Problem by GunnarValur

GunnarValur
Wed Oct 25 12:43:01 CDT 2006

I am not calling the progress bar at all. It is a simular prograss bara as
when Windows XP starts up just going round and round until the Splash screen
closes.



"Markus" wrote:

> > Any suggestions how I can fix this? (removing the progress bar isn't
> > an option and turning off CheckForIllegalCrossThreadCalls isn't
> > either)
>
> Most probably you should take care of the update of the progress bar (I
> am assuming, you are settings a new value of the progress bar).
>
> The call "myProgressbar.Value = xyz" is maybe from another thread. So be
> sure, you call it via myProgressBar.BeginInvoke(SomeMethod). And in this
> method, you can set the new value of the progress bar.
>
> hth
> Markus
>