我有以下问题:
Console.WriteLine("Starting");
Stopwatch stopWatch = new Stopwatch();
int delay = 1 * 60 * 1000;
int waitTime = delay - (int)(DateTime.Now.Second * 1000);
int time;
Console.WriteLine("PRE-Sleep");
Thread.Sleep(waitTime);
Console.WriteLine("AFTER-Sleep");
输出是:
Starting
PRE-Sleep
Unhandled Exception: System.TypeLoadException: A type load exception has occurred.
at System.Threading.Thread.StartInternal () [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: A type load exception has occurred.
at System.Threading.Thread.StartInternal () [0x00000] in <filename unknown>:0
将 Thread.Sleep(waitTime) 更改为 Thread.Sleep(1) 会产生以下输出:
Starting
PRE-Sleep
AFTER-Sleep
一切正常。
怎么会这样?
mono --version
Mono JIT compiler version 2.10.8.1 (Debian 2.10.8.1-5ubuntu1)
Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: x86
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: Included Boehm (with typed GC and Parallel Mark)
编辑:代码在使用 Xamarin 的 Windows 下运行良好