Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 自定义设置慢加载(ApplicationSettingsBase)_C#_.net_Application Settings_Applicationsettingsbase - Fatal编程技术网

C# 自定义设置慢加载(ApplicationSettingsBase)

C# 自定义设置慢加载(ApplicationSettingsBase),c#,.net,application-settings,applicationsettingsbase,C#,.net,Application Settings,Applicationsettingsbase,每次启动应用程序时,第一次加载自定义设置大约需要2秒钟 有什么办法可以加速吗 (或者,尽管存在速度限制,但这种方法是否被广泛使用。) 代码如下: public class MySettings : ApplicationSettingsBase { [UserScopedSettingAttribute()] public int MyInt { get { return (int)(this["MyInt"]); } set { this

每次启动应用程序时,第一次加载自定义设置大约需要2秒钟

有什么办法可以加速吗

(或者,尽管存在速度限制,但这种方法是否被广泛使用。)

代码如下:

public class MySettings : ApplicationSettingsBase
{
    [UserScopedSettingAttribute()]
    public int MyInt
    {
        get { return (int)(this["MyInt"]); }
        set { this["MyInt"] = value; }
    }
}
并称之为:

MySettings s = new MySettings();
int i = s.MyInt;

如何计时?@ken Breakpoint+F10。您可能正在计时调试器。使用System.Diagnostics.Stopwatch并在控制台或窗体应用程序中运行编译后的代码。@ken在发布模式下仍然超过1200毫秒。这是一个简单的例子。在实际情况中,对象更复杂,可能需要更多的时间。但无论如何,这太长了。