Can't specify the 'async' modifier on the 'Main' method of a console app

后端 未结 16 2072
后悔当初
后悔当初 2020-11-21 07:44

I am new to asynchronous programming with the async modifier. I am trying to figure out how to make sure that my Main method of a console applicati

16条回答
  •  故里飘歌
    2020-11-21 08:24

    For asynchronously calling task from Main, use

    1. Task.Run() for .NET 4.5

    2. Task.Factory.StartNew() for .NET 4.0 (May require Microsoft.Bcl.Async library for async and await keywords)

    Details: http://blogs.msdn.com/b/pfxteam/archive/2011/10/24/10229468.aspx

提交回复
热议问题