Search code examples
c#.net-coretaskopenvzvirtual-server

.NET Core Tasks not working on OpenVZ virtual server


I noticed that .NET Core 3 Tasks are not working on my Ubuntu 18.04 based virtual servers (the providers are Strato.de and HostEurope.de).

Here is a very basic test program:

static void Main(string[] args) {
    Console.WriteLine("Hello");
    Task.Delay(2000).ContinueWith(_ => Console.WriteLine("Fire"));
    Thread.Sleep(5000);
    Console.WriteLine("Exit");
}

The application should print "Hello"immediately, then after 2 seconds "Fire" and finally "Exit". This works fine on my Windows computer and also on my Ubuntu 18.04 computer.

But when I run the code on the virtual servers, the second message is never printed. Also Threading.Timer and Timers.Timer have the same problem, they almost never fire (sometimes, but very rarely, they do).

EDIT: Both virtual servers run on OpenVZ, at least this is what systemd-detect-virt says. I changed the title of the question accordingly.

Any idea what the problem could be?


Solution

  • This is a known bug and is going to be fixed in .NET Core 3.1.2

    See https://github.com/dotnet/runtime/issues/2070 and https://github.com/dotnet/coreclr/issues/26873