我有以下问题:
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)
编辑: 代码在Windows下使用Xamarin
正常工作答案 0 :(得分:0)
问题成立: 它与Thread.Sleep无关
该应用程序读取了一个cfg文件,该文件在linux下是misslinked。
Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)
解决了这个问题。