Question

I am writing a small .NET Windows Forms app, and I use the built-in Visual Studio settings to manage my programs config. I noticed an issue however that after I had added a StringCollection setting (to store a list of recently accessed documents), my program took eversoslightly longer to startup.

I ran a StopWatch over the programs initialisation and found that even calling StringCollection at all took the startup time from 100 milliseconds to 300 milliseconds. I know likely what you'll say, what's 200 milliseconds between friends?, but it seems strange to me that something so simple could cause such a delay.

So my question is, why is calling a StringCollection from the settings so slow, and is there any way I can avoid this delay?

Was it helpful?

Solution

It may well be loading extra assemblies which otherwise wouldn't be needed until later on.

You could use a Console.ReadLine() call just before you load the settings and see which assemblies are loaded after that when you run it in Visual Studio to test this theory.

OTHER TIPS

Did this happen just the first time you ran the program, or also on subsequent executions (with no rebuilding between). Also, was this a release build?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top