tags:

views:

162

answers:

1

The last few months my application grew bigger and bigger. It's runnable as Wpf .EXE and XBAP at the moment, both sharing the same code. At a few points in the application, the application locks. After invertigating I found out that the application is loading dlls from the GAC at these moments.

What happens is that the application starts, this takes a couple of seconds, and the user is presented with a logon screen. At the moment the user click the OK button to logon the application locks, because it has to load all kinds of dlls for the rest of the application. Because they're loaded from the UI thread all animations stop playing, event the mouseover of the OK button doesn't finish.

It started out as seconds, but at the moment at some points you'll have to wait a couple of minutes before the app continues. I think it's unexceptable.

Is there a way to move the loading of dlls from the GAC to another thread? So a "Please wait while application is loaded"-animation can be played? Or, even better, can I move the loading of all dlls needed to the start of the app, so there would be less waiting going on when working.

+2  A: 

Yes (for "seconds" at least; not sure it scales to "minutes") - at the login screen, just spin up a worker thread (perhaps with ThreadPool) that does something that requires those assemblies. This will cause them to load...

ThreadPool.QueueUserWorkItem(LoadAssemblies);
...
static void LoadAssemblies(object state)
{
    Widget1 widget = new Widget1(); // but just let it go (perhaps dispose it)
}

You are now off the UI thread, loading your assemblies while the user types their password.

Marc Gravell
I thought I tried a construction like that already, but this time it worked. Thanks!
Sorskoot