I would like to know what the point is of creating and starting a task, followed by a call to wait for the task. It's always been my belief that the point of tasks is for asynchronous programming, but this seems to just create more resources for a synchronous operation.
var task1 = System.Threading.Tasks.Task.Factory.StartNew(() => CheckMaps());
task1.Wait();
var task2 = System.Threading.Tasks.Task.Factory.StartNew(() => CheckTicker());
task2.Wait();
Here are a few resources I found while trying to find an answer:
SO: ...calling Task.Wait()...after an asynchronous operation... - results of task.Wait() and task.Result() after task declaration.
Stephen Toub - Task.Wait and Inlining - Task.Wait() can pull a task out of the scheduler and execute it inline. (In this case it wouldn't apply because the task has already started.)
SO: Memory Barrier Generators - Creating a task creates memory barriers.
These resources mostly answered my concerns, but I can't help but feel like I'm breaking something when I replace all these tasks with standard method calls.
Is there something that specifically Task.Factory.StartNew()
does in the background that would be significantly different than a regular method call?