Miminum set of the async/await portability libararies.
These packages includes:
- Back-porting implementation for .NET 3.5
- Type forwarding for .NET 4.5 or later
So, these libraries are supported in mixed versions with both 3.5 and 4.5 (but not with .NET 4). You can create a library with .NET 3.5 with the back-ports, and then, consume it from an app with .NET 4.5.
I'd like to use async/await functionality in Unity game engine.
The runtime version of Mono used by Unity is 2.8 which is nearly equivalent to .NET 3.5 and does not have the
In this background, I have implemented back-porting libararies of the classes related to async/await to .NET 3.5, especially Unity.
The back-porting libararies includes the
TaskAwaiter, and so on.
The implementation is based on code in https://github.com/Microsoft/referencesource, I use tunnelvisionlabs/dotnet-threading#90 as a reference, and the MinimumAsyncBridge has the same problem as the dotnet-threading.
Task class in .NET has multiple roles:
ThE back-porting libararies implement only 2. and 3. (Minimum requirement of async/await is 3.).
For 1., only a few overloads of
WhenAll are implemented (but, it's simplified implementation).
If you would need the full threading capability, you could use another threading library and interop by using
The debbugability of the
Task in the MinimumAsyncBridge is poorer than original
Stack trace information is lost because the back-port does not have
which is impossible without runtime support.
Notice: Use in Unity
The back-porting libararies contains classes required for async/await. However, the C# 5.0 (or later) compiler is also required. Thus:
- you can use async/await with .NET 3.5 and these libararies with the C# 5.0 compiler.
- if you create a DLL with the C# 5.0 compiler and copy it to a Unity project, you can use async/await in the DLL.
- but, you can still not use async/await with the compiler bundled with Unity.