Thanks for your reply Jon, much appreciated.
I have posted a sample solution to:
http://www.kevinandkiran.com/splash_screen_tester.zip
It is in VB.
This is essentially my current solution, although interestingly I get
errors in different places to my actual program.
This seems to work about 90% of the time, although I am getting the
occaisional "Cross-thread operation not valid:" exceptions on line 40
(Label2.Text &= ".") of FormSplash, despite the fact that I have
invoked it.
I have also had to comment out line 21
(frmSplash.SetOwnerThreaded(frmMain)) of modMain as this too is causing
the exception. Strangely though my actual program allows this.
Line 11 should also really be frmLogin.ShowDialog(frmSplash) instead of
frmLogin.ShowDialog() so that the login screen appears in front of the
splash screen. Again, my program allows this.
Thanks again
Kevin
> Thanks for your reply Jon, much appreciated.
>
[quoted text clipped - 8 lines]
> (Label2.Text &= ".") of FormSplash, despite the fact that I have
> invoked it.
I suspect that problem is because you've got a race condition - you can
end up calling InvokeRequired (and changing the status message) before
you've called ShowDialog - in other words, before you start the message
loop for that thread. You're also *creating* the splash screen on a
different thread to the one you're starting it on - that, again, sounds
like a bad idea.
There's also the problem that you're never running a message loop for
the splash screen as far as I can see.
I'm not an expert on this topic, but I would suggest that:
1) You only create a GUI control on the thread you're going to run it
on
2) You call Application.Run before calling Show.
> I have also had to comment out line 21
> (frmSplash.SetOwnerThreaded(frmMain)) of modMain as this too is causing
> the exception. Strangely though my actual program allows this.
That sounds like a really bad idea (calling it, I mean). Setting the
owner of one form to be a form which has a different message thread
can't be a good idea, IMO.
> Line 11 should also really be frmLogin.ShowDialog(frmSplash) instead of
> frmLogin.ShowDialog() so that the login screen appears in front of the
> splash screen. Again, my program allows this.
Hmm... not sure on this one.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Kevin - 29 Jan 2007 09:35 GMT
ok, thanks for looking Jon.
Kevin