Async programming

Fire and forget

Task.Run (() => WriteSchedule(writeFile));

private void WriteSchedule(StreamWriter writeFile)
{
Thread.Sleep(10000);
writeFile.WriteLine("Calculate");
}

Doesn't work, also not when returning a Task:
private async void WriteSchedule(StreamWriter writeFile)
{
Thread.Sleep(10000);
writeFile.WriteLine("Calculate");
}

Calling WriteSchedule will last 10 seconds.

About Tasks

http://stackoverflow.com/questions/10179691/passing-arguments-with-changing-values-to-task-behaviour#10179856

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License