To run the code asynchronously (e.g. using async / await) I need the right task. Of course, there are several predefined methods in the structure that cover the most common operations, but sometimes I want to write my own. I am new to C #, so it is possible that Im doing it wrong, but Im at least not completely satisfied with my current practice. See the following example of what I am doing:
public async Task<bool> doHeavyWork()
{
var b1 = await this.Foo();
var b2 = await Task.Run(()=>Bar());
return b1 & b2;
}
public Task<bool> Foo()
{
return Task.Factory.StartNew(() =>
{
return false;
});
}
public bool Bar()
{
return false;
}
, Foo, " , , imho. - , , Bar, , , , async ( , BarAsync), Task.Factory.StartNew . , , " , , , , .
, : ? " " ( , )?
Servy, . , ( ).