Re: whats faster, initialize component, or form load?
- From: "Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 3 Jul 2007 14:47:34 -0400
Roger,
In this case, no, it is not going to make the program faster. You are
doing the same work, which is going to take the same amount of time, just in
a different order. The order of operations for your program is as follows
(generally):
Create form instance
Show form
Load event on form is called
All of this is synchronous. This is an important distinction.
If hypothetically, the whole process takes 10 seconds, and it takes 5
seconds to run the Load event on the form, then moving the code that takes
five seconds to the constructor is not going to make the code run any
faster. You are still going to take five seconds to perform that work, and
the overall time will not change.
I mentioned synchronous before becuase if you can do the work
asynchronously, then you could see a benefit in speed if you delegate the
work to another thread. However, you have to figure out whether or not the
work can be performed asynchronously.
--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx
"roger_27" <roger27@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:3BE339FD-0096-475A-8C5E-FB8CA3D89CE9@xxxxxxxxxxxxxxxx
hey, I have some preliminary code in my program (check for a certain file,
define a like 15 variables) and I put it in the form load. I recently got
the idea to make a method for it, and do it in the constructor method
instead.
would this make the load time of the program faster? or is it the same as
leaving it in the form load.? any thoughts or ideas on this?
thanks.
.
- Follow-Ups:
- Prev by Date: Re: Comparing generic value/string types
- Next by Date: Trying to run a query while in a reader loop...
- Previous by thread: Re: whats faster, initialize component, or form load?
- Next by thread: Re: whats faster, initialize component, or form load?
- Index(es):
Relevant Pages
|
Loading