2

我有以下问题:

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 下运行良好

4

1 回答 1

0

问题成立:它与 Thread.Sleep 无关

该应用程序读取了一个在 linux 下被错误链接的 cfg 文件。

Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)

解决了这个问题。

于 2013-05-07T14:14:25.300 回答