   [.net] WPF Startup Time Question
  Hello,I have an application that is taking a long time to startup (about 8-10 seconds...i do have a splash screen showing during this time).   I decided to speed it up by getting rid of some startup methods, or changing them around...but it's really weird what's happening, and i'm not sure why it's doing this.(To explain what's going on i'm going to give an example sort-of of what's happening)After some profiling, I found that my main window constructor was taking about 10 seconds to finish, but 95% of that time, was taken by my first startup method, (we'll call it connectToWebService()).So my constructor looks like this//////  Version 1 (Original)///public wndMain(){    //takes 9 seconds to get through this method    connectToWebService();    //the rest is really quick    readXMLFile();    checkForUpdates();    readLocalSettings();}I changed the connectToWebService method, to only connect to the webservice if it actually needs to, otherwise, just use the data we got from it last time (something similar to that).  So i got this method really fast...but then the next method starting taking about 9 seconds to get through.//////  Version 2///public wndMain(){    //changed this to work differently, really fast now (10ms or so)    connectToWebServiceIfNeeded();    //now takes 9 seconds to get through this method    readXMLFile();    //these are still really quick    checkForUpdates();    readLocalSettings();}So then what I did was make the readXMLFile() method faster, but the same thing happened, the time problem just jumped down to the next method.  I optimized everything I could and got the whole constructor to execute really fast...but the load time problem is still there...the application finishes the constructor in about 100ms, then I have no idea what happens, but my window still doesn't show for the same old 10 seconds.How do I figure out what's slowing me down?  Is this common with WPF applications?  Once the window constructor is done executing, shouldn't the window be launched immediately?If someone could shed some light for me that'd be awesome.   
  Does it also take that long if you start your program outside Visual Studio? Do you write a lot of stuff to the console during startup? What does the profiler say about readXMLFile?   ;  The profiler should be able to tell you more than just the constructor is taking a long time, it should tell you exactly what lines are taking so long.I have had this pattern appear a few times for me. Every time, it has been either a lazy-initialized object or a static constructor. Be sure to watch out for both of those. There is nothing wrong with either performance-wise, its just that they can be a hard one to find, and they often show up in this kind of pattern when slow.   ;  Any chance you could improve the performance by using multiple cores? Or at least improve preceived performance?Anyway, profile first!   