Based on my understanding, the process of loading modules can be divided in two separate steps: loading the assembly containing the module and initializing the module.
For the first step, I don't believe using threads or similar approaches would affect the loading time of an assembly, as the threads would have to wait for the disk to complete their requests to read the corresponding files.
As for the second step, it might be possible to modify the LoadModulesThatAreReadyForLoad
method to load each module in a separate thread (for example, by executing the "
this.InitializeModule(moduleInfo); " line inside the threads.) I don't know if such approach would report any performance improvements when initializing modules, but you will have to consider how to manage the dependencies between modules
(modules that are related by a dependency should not be initialized concurrently) and how to check when a module has completed it's initializing process.
Also, if your modules have a complex initialization logic, you could create threads inside the
Initialize method of the module. However, in this case you will need to make sure that all threads have finished their work before returning from the
Initialize method (if not, the module could be declared as
Initialized while some of its threads could still be working in the background.)
In my opinion, you could first develop the modules and check how much they take to load before searching how to improve their loading time, as it might be possible for the modules to load fast enough without requiring any modification in the initialization
On the other hand, if you are experiencing a poor performance when initializing modules, it would be helpful if you could provide us with more information about what initialization logic you have in your modules, so that we could help you improve its initialization
time, as its possible that some of its logic could be moved to other components of the module.