Re: whats faster, initialize component, or form load?



On Tue, 03 Jul 2007 16:28:39 -0700, Lit <sql_agentman@xxxxxxxxxxx> wrote:

Interesting, how does asynchronously make it faster?
please enlighten.

It depends. In some cases, it won't. But if you have multiple elements to your initialization that are mutually independent (that is, the results of some initialization are not required in order to perform other initialization), then you could see improved performance by processing them asynchronously for a variety of reasons. The most common being that on a multi-CPU computer, each asynchronous thread can do work in parallel with other asynchronous threads.

For example, suppose that when initializing you have two different calculations you need to do, neither of which depend on each other. Suppose they both take 500 milliseconds. Doing them synchronously, you would take 1000 milliseconds, but doing them asynchronously you could theoretically do them both in only 500 milliseconds, assuming you have at least two CPUs to handle the processing.

Another common reason would be if the initialization required a variety of i/o to different subsystems or remote entities. An example of this might be if you have to query two different web servers. Even if you only have one CPU, you could still see an improvement in speed, for similar reasons as the CPU-bound case. The difference being that in this case you are waiting for a remote server instead of a CPU. But the basic logic is the same: if you have to wait 500 milliseconds for each server, doing the requests synchronously would delay you 1000 milliseconds, but doing them asynchronously in parallel would delay you only 500 milliseconds.

Now, all that said, there's little about your problem description that suggests to me that you would gain much benefit from changing your initialization at all, never mind making some or all of it happen asynchronously. In particular, the only thing that sounds remotely slow is the "check for a certain file", so you have no other slow item to do in parallel with that. Even that operation is unlikely to be slow enough for you to be concerned with its performance anyway. Say, for example, you had to make two such checks. Even so, unless you were trying to instantiate a number of this class all at once (like thousands or more), I doubt that you'd achieve any practical performance improvement by parallelizing the operations.

Basically, it appears to me that you are worrying about something that simply does not warrant concern.

Pete
.



Relevant Pages

  • Re: whats faster, initialize component, or form load?
    ... just because the parallalisation needs to be processed. ... to your initialization that are mutually independent (that is, ... Suppose they both take 500 milliseconds. ... waiting for a remote server instead of a CPU. ...
    (microsoft.public.dotnet.languages.csharp)
  • SecurityException during deserialization
    ... initialization is delayed after the deserialization or the server creates ... administrators account and no code access security restrictions have been ... how these can be removed or how the static initialization of classes can be ... public override string ToString() ...
    (microsoft.public.dotnet.framework.remoting)
  • Initialization problems with hidden application
    ... Now I am ready to implement the application, and I want to enable the Server ... that is assigned in initialization. ... and I cannot write to the log file. ... variable (GLogFilePath)? ...
    (borland.public.delphi.language.objectpascal)
  • WebSphere Installation
    ... I've installed WebSphere version 5.0 on AIX 5.2 and) faced small ... ADMU3200I: Server launched. ... Server launched but failed initialization. ...
    (comp.unix.aix)
  • Re: Error in LDAP Service. Help!
    ... It is a Windows 2000 Server with SP4 and fully ... Complete error messages: ... The server failed to start due to an initialization error. ...
    (microsoft.public.win2000.active_directory)