views:

397

answers:

1

I have a Visual Studio add-in which opens a modal WPF window.

My problem is that the first time round, it takes 4 seconds for the window to appear which is a clear disservice to the client. So I'm wondering if there is a way to optimize this away?

Is there some kind of nifty code to preload the PresentationFramework (or whatever is slowing the thing down) when the add-in starts, rather than when it is actually used?

A: 

You may want to check your output window in VS to see if the pause is actually from loading DLL's that it didn't have already loaded. If that's the case, then you can try this:

When the application starts, load a blank hidden WPF window and close it.

This should "pre-load" the presentation framework (if that's actually the problem - its sometimes hard to tell with these cases.), so that when you call the needed window its ready to open.

Not the best solution, but users can usually wait 4 seconds in the first place.

StingyJack
And what is wrong with that?
StingyJack
Four more seconds on load time, that's what. If all your addins did that kind of thing, you'd end up waiting longer and longer for vs to load. Better to throw off a worker thread and load those assemblies in the background.
Will