Join 117,290 C# Programmers for FREE! Ask your question and get quick answers from experts. There are 2,496 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!
In order to make your form start up fast(very fast) you need... Needed Items... 1)Timer(startUpTimer) 2)Your Form_Load() Code
So here is what you do...
First you create a timer called startUpTimer. Set the enabled property to false. Set the startUpTimer Interval to 1. Then go to your Form's Load() property and cut all of the text out, then type startUpTimer.Enabled = true; then press Enter and type startUpTimer.Start();. Double click the startUpTimer and paste in the code that you cut from the Form's Load() Property.
Run your form and it should be much faster loading.
Why even use a timer? That is just a waste of resources and on top of that you never stop the timer. So it will continue running during your applications execution, slowing down every process. Especially at 1ms for the Tick event.
And to add insult to injury, the code you moved from the Load event into the Tick event of the Timer is going to execute every time the event fires.
The form will load the fastest, if you don't use a timer at all. Anytime you incorporate a timer into the load event of a form, you are only slowing down the load time.
-10000000000 kudos for giving out really bad advice.
Why even use a timer? That is just a waste of resources and on top of that you never stop the timer. So it will continue running during your applications execution, slowing down every process. Especially at 1ms for the Tick event.
And to add insult to injury, the code you moved from the Load event into the Tick event of the Timer is going to execute every time the event fires.
The form will load the fastest, if you don't use a timer at all. Anytime you incorporate a timer into the load event of a form, you are only slowing down the load time.
-10000000000 kudos for giving out really bad advice.
totally agree. logically, the code that was just moved from the Form_Load() event to the timer's event will now run atleast 1ms slower since it will take that long for the timer to start. I fail to see how this "speeds up" anything.
Why even use a timer? That is just a waste of resources and on top of that you never stop the timer. So it will continue running during your applications execution, slowing down every process. Especially at 1ms for the Tick event.
And to add insult to injury, the code you moved from the Load event into the Tick event of the Timer is going to execute every time the event fires.
The form will load the fastest, if you don't use a timer at all. Anytime you incorporate a timer into the load event of a form, you are only slowing down the load time.
-10000000000 kudos for giving out really bad advice.
totally agree. logically, the code that was just moved from the Form_Load() event to the timer's event will now run atleast 1ms slower since it will take that long for the timer to start. I fail to see how this "speeds up" anything.
Sorry I did forget to stop the timer, if you want to stop the timer put it in the timer_Tick() property. Make sure that it is the last line of your timer code.
You say that you can not see how it effects the timer, well it does. As soon as i did that i noticed it went so much faster.
You could just put the code for your form's load event in the Form_Shown event. That way, the form is already visible when it starts loading, making it 'Appear' to load faster. I bet that's what the timer thing is doing.
Why even use a timer? That is just a waste of resources and on top of that you never stop the timer. So it will continue running during your applications execution, slowing down every process. Especially at 1ms for the Tick event.
And to add insult to injury, the code you moved from the Load event into the Tick event of the Timer is going to execute every time the event fires.
The form will load the fastest, if you don't use a timer at all. Anytime you incorporate a timer into the load event of a form, you are only slowing down the load time.
-10000000000 kudos for giving out really bad advice.
totally agree. logically, the code that was just moved from the Form_Load() event to the timer's event will now run atleast 1ms slower since it will take that long for the timer to start. I fail to see how this "speeds up" anything.
Sorry I did forget to stop the timer, if you want to stop the timer put it in the timer_Tick() property. Make sure that it is the last line of your timer code.
You say that you can not see how it effects the timer, well it does. As soon as i did that i noticed it went so much faster.
you seem pretty new to programming. what you are saying is not logical. all you are doing is moving the code around and creating a pause(1ms) before it runs. leaving it in the Form_Load() Event would not have the pause, therefore, it would actually be faster to leave it in the Form_Load() Event.
I don't know how else to explain this, but you are giving horrible advice.
You could just put the code for your form's load event in the Form_Shown event. That way, the form is already visible when it starts loading, making it 'Appear' to load faster. I bet that's what the timer thing is doing.
you are correct. that is all it's doing. it appears to "run faster" but that's only an illusion because the form shows faster.
I would like the OP to do this little test:
1. create a form with a textbox on it. 2. create a timer and set it to run in 1ms 3. in the Form_Load() Event, enable the timer(so that it runs). 4. in the Tick Event for the timer, put in:
5. now run it, and see how long it takes for the textbox to get the string. I guarantee you that the form will show a blank box, then 5 seconds later, the data will show up in the textbox. you will also notice that you cannot do anything with the form either(which could be fixed using a different thread).
now did that really make the application "run faster"? no. it made the form show faster, but the processing is still going.
This post has been edited by eclipsed4utoo: 11 Jul, 2008 - 07:22 PM
You could just put the code for your form's load event in the Form_Shown event. That way, the form is already visible when it starts loading, making it 'Appear' to load faster. I bet that's what the timer thing is doing.
you are correct. that is all it's doing. it appears to "run faster" but that's only an illusion because the form shows faster.
I would like the OP to do this little test:
1. create a form with a textbox on it. 2. create a timer and set it to run in 1ms 3. in the Form_Load() Event, enable the timer(so that it runs). 4. in the Tick Event for the timer, put in:
5. now run it, and see how long it takes for the textbox to get the string. I guarantee you that the form will show a blank box, then 5 seconds later, the data will show up in the textbox. you will also notice that you cannot do anything with the form either(which could be fixed using a different thread).
now did that really make the application "run faster"? no. it made the form show faster, but the processing is still going.
I actually am not very new to programming, I have about 5 years experiece. What I meant was that it shows faster so you were right. I could not think of the right word(s). I'm Sorry but it did make the form show faster, that is all I was really going for.
You could just put the code for your form's load event in the Form_Shown event. That way, the form is already visible when it starts loading, making it 'Appear' to load faster. I bet that's what the timer thing is doing.
you are correct. that is all it's doing. it appears to "run faster" but that's only an illusion because the form shows faster.
I would like the OP to do this little test:
1. create a form with a textbox on it. 2. create a timer and set it to run in 1ms 3. in the Form_Load() Event, enable the timer(so that it runs). 4. in the Tick Event for the timer, put in:
5. now run it, and see how long it takes for the textbox to get the string. I guarantee you that the form will show a blank box, then 5 seconds later, the data will show up in the textbox. you will also notice that you cannot do anything with the form either(which could be fixed using a different thread).
now did that really make the application "run faster"? no. it made the form show faster, but the processing is still going.
I actually am not very new to programming, I have about 5 years experiece. What I meant was that it shows faster so you were right. I could not think of the right word(s). I'm Sorry but it did make the form show faster, that is all I was really going for.
but in any case where there is going to be computed data on the form that is loaded during the Form_Load() Event, this is useless. if you just want to load a standard blank form, then yes, it will be fine showing it before any processing is done. but all of the applications that I have written have always had data on the form when it loaded(normally pulled from a database). so this would be useless to me.
This post has been edited by eclipsed4utoo: 12 Jul, 2008 - 06:35 AM