I cannot understand why the following code will not work:
var task = new Task(() => { });
task.Start();
if (task.Wait(10000))
{
logger.Info(\"Works\");
It works:
var task = new Task(() => { });
task.Start();
if (task.Wait(10000))
{
Console.WriteLine("yes");
}
else
{
Console.WriteLine("no");
}
And gives the output yes as expected. You must be doing something else which is causing it to not work. In the given form, without context of what / where you are doing it, it works.
Even this abomination works:
var task = new Task(() =>
{
var task1 = new Task(() =>
{
});
task1.Start();
if (task1.Wait(10000))
{
Console.WriteLine("yes");
}
else
{
Console.WriteLine("no");
}
});
task.Start();
if (task.Wait(10000))
{
Console.WriteLine("yes");
}
else
{
Console.WriteLine("no");
}