简体   繁体   English

为什么从Settings调用StringCollection会变慢?

[英]Why is calling StringCollection from Settings slow?

I am writing a small .NET Windows Forms app, and I use the built-in Visual Studio settings to manage my programs config. 我正在编写一个小的.NET Windows Forms应用程序,我使用内置的Visual Studio设置来管理我的程序配置。 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. 我注意到一个问题,但是在我添加了一个StringCollection设置(存储最近访问过的文档列表)后,我的程序启动时间略长。

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. 我在程序初始化时运行了一个StopWatch,发现即使调用StringCollection,启动时间也从100毫秒增加到300毫秒。 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. 我知道你会说什么,朋友之间的距离是200毫秒?但是我觉得这么简单的事情会导致这样的延迟。

So my question is, why is calling a StringCollection from the settings so slow, and is there any way I can avoid this delay? 所以我的问题是,为什么从设置调用StringCollection这么慢,有什么方法可以避免这种延迟?

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. 您可以在加载设置之前使用Console.ReadLine()调用,并在Visual Studio中运行它以查看此理论之后查看之后加载的程序集。

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? 此外,这是一个发布版本?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从保存在设置中的stringCollection中删除字符串 - How delete string from stringCollection saved in settings StringCollection在Settings.Default.Reload()上更改 - StringCollection changes on Settings.Default.Reload() 应用程序设置中的 StringCollection 未存储 - StringCollection in application settings doesn't get stored 使用LINQ-to-Entities查询中的“应用程序设置”中指定的StringCollection - Using StringCollection specified in Application Settings in a LINQ-to-Entities Query WPF,不适用于 ListView 中的 Properties.Settings (StringCollection) 的 OnPropertyChanged - WPF, doesn't work OnPropertyChanged for Properties.Settings (StringCollection) in listView 如何从C#中的StringCollection中删除重复项? - How to remove duplicates from a StringCollection in c#? 从StringCollection拆分值以获取参数 - Split value from StringCollection to get as parameters 从applicationSettings读取设置非常慢? - Reading settings from applicationSettings is very slow? 从C#调用操作系统设置 - Calling OS settings from C# System.Collections.Specialized.StringCollection 设置在调试和发布中工作正常但在部署时崩溃? - System.Collections.Specialized.StringCollection settings work fine in Debug and Release but crash on Deployment?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM