Unusually slow windows forms

LHandy

Well-known member
Joined
May 27, 2005
Messages
50
Programming Experience
5-10
[RESOLVED] Unusually slow windows forms

I've been ignoring this problem in my program for a while. When the program is executed, the hard drive spins and spins for a good 10 seconds until the program loads. Where the same application in VB6 would have been instantaneous.

There is virtually nothing in my Form_Load event, and I'm using a Main() sub to do the initial stuff to determine what to do first, which also doesn't have much in it either.

Basically, it's just a program that displays a form when it opens. That's about it. I've done some research and other people have this problem also. Some say it's in the constructor. I have a number of controls on the main form, but not really so much to where it should be slowing down this far.

I'm really at a loss for ideas on how to fix this. I have never played with (or even fully understand) multithreading, and doubt it would help anyway as there isn't much going on. Does anybody have any suggestions?
 
Last edited:
I should also mention that I've tried putting a small "Loading" window up while the main form is loading. All it had was a label. And it was only displayed for a split second. Which tells me whatever is going on is happening before the startup object Sub Main() is called. Here's the code for that.

VB.NET:
Public Sub Main()
	Dim myProcess() As Process = Process.GetProcessesByName("MyProgram'sName")
	If myProcess.Length = 1 Then
		Dim mainForm As frmMain = New frmMain
		loading.show 'Publicly declared elsewhere
		mainForm.show
	End If
End Sub

Then loading is closed at the end of Form_Load in mainForm

So I know it's not frmMain that is slowing it down.
 
Basically what you're doing is showing a splash screen. Here's an article on doing just that. I haven't read it or used it, but given that it's from MSDN I'd hope that it would avoid whatever inherent problem your current code contains.
 
Yeah. A splash screen would be fine -- at least the user would know that it's doing SOMETHING! But the problem is it seems to lag even before Sub Main(), the first place I could possibly start the splash screen.

I just want to know why it's so slow before the main form is even declared... as it apparently is. Hopefully someone knows. The startup object is Main() and all code in it isn't executed until after it stops lagging.
 
For those with similar problems I found a way to increase the speed.

VS.NET comes with a program called "Dotfuscator" which removes unused classes, methods and fields. It also helps protect against reverse-engineering (crack & keygen making, basically)

It increased the load time of two of my programs dramatically.

[RESOLVED]
 
Back
Top