Can't understand the syntax of Async/Await to rewrite the code?

In General, use just a task wrote this code:
private void makeExperiment()
 { 
 Task task = new task(
 () => _experiment.Start(data)
);

 var awtr = task.Actual();
awtr.OnCompleted(
 () =>
{
 //something to do after
});
task.Start();
 }

How to rewrite it in the style of C# 5 , as I understand it must be so
private void makeExperimentAsync()
 { 
 await _experiment.StartAsync(data);
 //something to do after
 }

But what should be the method StartAsync ? just wrap it in a Task , but if I don't want to return from the stream to write return Task.Run( //...) does not work, you need to write await Task.Run, so that the await must be async method inside and outside?
July 2nd 19 at 13:53
1 answer
July 2nd 19 at 13:55
Something like that.
private async Task makeExperimentAsync()
 { 
 await _experiment.StartAsync(data);
 //something to do after
 }

private async Task makeExperiment()
 { 
 await TaskFactory.StartNew( () => _experiment.Start(data) )
.ContinueWith( (e) => 
{
 //something to do after
});
}
It turns out almost the same as I had, and I wanted to Start method also became hasnandani - Hermann.Schowalter commented on July 2nd 19 at 13:58
: This is the question and the answer. Asked to rewrite - here. In fact the review. What do you mean asynchronous? If very rough, async / await is about asynchrony not work, it's about the fact that at the time of the code execution if found a call to an async method with await keyword, it runs asynchronously in a thread pool, the UI will not visitsa, but it is expected the result of the execution (or completion of the method) . It's sugar for easy work with the methods that execute for a long time, and neither of which is async it is not.
I.e. If you write something like this:
await _experiment.StartAsync(data);
await _experiment.StartAsync(data);
await _experiment.StartAsync(data);
It does not mean that the method call will be immediately executed is the next line, this means that waiting until the method is finished and only then moving on to the next line.
If you want it asynchronous behavior in the classical sense (started, not expecting anything, the result in the callback method), then your code is quite right to life. - jazmyne.Bernier commented on July 2nd 19 at 14:01

Find more questions by tags C#