I have the following simple code:
class Program
{
public static readonly List<int> Years = BuildList();
static void Main(string[] args) { }
private static List<int> BuildList()
{
var t = Task.Run(() => x());
t.Wait();
return new List<int>();
}
private static void x()
{
Console.WriteLine("Hello World");
}
}
After debugging, it is x()never entered, but t.Wait()never completed / not returned and does not freeze. Can anyone explain this weird behavior?
Doesn't look like there are any blocking UI calls, all I can guess is that threadpool is somehow maximized?
If I delete the call .Wait(), then x()it will eventually be entered.
Please note that calling BuildList()from Mainworks fine.
source
share