|
-
Aug 21st, 2004, 06:39 AM
#1
Thread Starter
Frenzied Member
Execute code after Form Load [Resolved]
I need to execute this code during form load but the problem is that it either takes ages to show the form or does things I don't want it to do. Is there a way to run code in parallel with the form load so that the form still shows, but the extra code that is required to execute at the start, still operates?
An example would be if you try to hide the form in the Form_Load procedure, as soon as the procedure has finished, the form shows itself in the taskbar, even if you have chosen to hide it.
Last edited by Ideas Man; Aug 21st, 2004 at 07:50 PM.
I use Microsoft Visual Basic 2005. (Therefore, most code samples I provide will be based around the .NET Framework v2.0, unless otherwise specified)
-
Aug 21st, 2004, 08:54 AM
#2
Hyperactive Member
I would simply run the code in a new thread
Whadayamean it doesn't work....
It works fine on my machine!

-
Aug 21st, 2004, 12:33 PM
#3
PowerPoster
Hi,
If you use sub Main in the module as your startup object, you could try:
VB Code:
Module Module1
Public frm1 As Form
Sub Main()
FirstAction
frm1 = New Form1
frm1.ShowDialog()
End Sub
Private SubFirstAction()
MessageBox.Show("This is your FirstAction code")
End Sub
End Module
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Aug 21st, 2004, 01:15 PM
#4
Frenzied Member
Another approach is to have a splash screen, maybe with a bogus progress bar (like when you start Windows) or animation. Then you can do lots of stuff before you show your main form, and the user doesn't think your app is hanging or slow.
Mike
-
Aug 21st, 2004, 06:46 PM
#5
Thread Starter
Frenzied Member
Originally posted by CyberHawke
I would simply run the code in a new thread
How would i do that?
And thanks for those other suggestions, but they really only do what it does now, but in a different way. Taxes suggestion would be stuck in the subroutine before loading the form so it's just moving the problem to a different location.
I need it like a timer so that it executes in parallel, CyberHawke sounds like he is on the track.
I use Microsoft Visual Basic 2005. (Therefore, most code samples I provide will be based around the .NET Framework v2.0, unless otherwise specified)
-
Aug 21st, 2004, 07:49 PM
#6
Thread Starter
Frenzied Member
Thankyou CyberHawke, you solved my problem.
For all those looking for a solution, I found the Multi-threadding solution at here: http://msdn.microsoft.com/library/de...eThreading.asp
I use Microsoft Visual Basic 2005. (Therefore, most code samples I provide will be based around the .NET Framework v2.0, unless otherwise specified)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|