async/await keywords not available in .net 4.0

前端 未结 4 576
清歌不尽
清歌不尽 2020-12-03 04:39

I would like to use the async/await in C# 4.0 and I have installed the following package:

http://www.nuget.org/packages/Microsoft.Bcl.Async/

The problem is t

4条回答
  •  温柔的废话
    2020-12-03 05:34

    Async/Await have been introduced with C# 5.0 and .NET Framework 4.5

    more information here:

    Asynchronous Programming with Async and Await (C# and Visual Basic)

    Asynchronous Programming in C# 5.0 using async and await

    If you are using Framework 4 as I do in enterprise you can use other workarounds. You can use a NuGet package that allows you to use these features.

    Using async/await without .NET Framework 4.5

    Just install it from NuGet package manager:

    Install-Package Microsoft.Bcl.Async

    Extracted from NuGet Gallery:

    This package enables Visual Studio 2012 projects to use the new 'async' and 'await' keywords. This package also includes Task-based extension methods that allow using some of the existing asynchronous APIs with the new language keywords. Windows Phone Silverlight 8 projects can use this package to get access to async extension methods for the networking types.

提交回复
热议问题