你好,我正在尝试创建一个全局类,以便在我的项目中使用。我打算将其用作默认模板,由于我是新手,请耐心等待;)
Stopwatch Masterstopwatch = new Stopwatch();
#if DEBUG
private static void ApplicationLogStart()
{
StartTime = DateTime.Now;
Masterstopwatch.Start();
String eventName = "Program Loaded";
String errorDetails = "Program has started Succesfully";
DataLogEntry(eventName, errorDetails);
}
private static void ApplicationLogclosing()
{
String eventName = "Program is closing";
String errorDetails = "Program has closed Succesfully";
DataLogEntry(eventName, errorDetails);
StopTime = DateTime.Now;
Masterstopwatch.Stop();
Benchmark(StartTime,StopTime,Masterstopwatch.Elapsed);
}
#endif
我怀疑我的设计存在根本性缺陷,因为我想要在不使用方法的情况下全局声明Stopwatch Masterstopwatch = new Stopwatch();。我怀疑这是不可能的,但我需要问一下。
private static readonly _stopwatchProxy = new StopwatchProxy()
每个AppDomain只调用一次。请参阅http://msdn.microsoft.com/en-us/library/aa645612.aspx获取信息。 - Dr. Andrew Burnett-Thompson