none
Background-load assemblies and their references to prevent delay on first use RRS feed

  • Question

  • In our application, the first time the user uses a form that uses a (third party) assembly they get a delay.

    From a developer's point of view, this is just how things work.

    However, you don't want a 3 or 4 second delay during a product demo.


    Therefore, is there any way of forcing the loading of an assembly and its referenced assemblies?

    This would ideally be on a background thread as our application was opening.

    Tuesday, March 4, 2008 9:26 AM

Answers

  • Hi James,

     

    You can load assembly by using Assembly.Load or Assembly.LoadFrom methods.

     

    Also if you want to significantly increase speed I suggest you to precompile these assemblies in separate thread using

    System.Runtime.CompilerServices.RuntimeHelpers.PrepareMethod method.

    Just call this method on all methods from thrid party assemblies.

     

    Tuesday, March 4, 2008 9:40 AM

All replies

  • Hi James,

     

    You can load assembly by using Assembly.Load or Assembly.LoadFrom methods.

     

    Also if you want to significantly increase speed I suggest you to precompile these assemblies in separate thread using

    System.Runtime.CompilerServices.RuntimeHelpers.PrepareMethod method.

    Just call this method on all methods from thrid party assemblies.

     

    Tuesday, March 4, 2008 9:40 AM
  • I had a quick go with Assembly.Load, but had problems with it not finding the other 3rd party assemblies the assembly references.

    I don't know if I should have been handling the AssemblyResolve event.

     

    I'm not sure whether if I do all the loading on a separate thread whether this will affect the main application thread anyway.

    When I showed the form on another thread it didn't seem to make any difference in the main thread.

    Thursday, March 6, 2008 11:08 AM