HouraiTeahouse / FantasyCrescendo

A 2.5D Touhou Platform Fighter, By the fans, for the fans.
https://docs.houraiteahouse.net/FantasyCrescendo
GNU General Public License v2.0
107 stars 29 forks source link

Replace ITask and ITask<T> with System.Threading.Tasks.Task #256

Closed james7132 closed 6 years ago

james7132 commented 7 years ago

This is one of the changes after switching to .NET 4.6: async language support. This will allow us to stop maintaining our async promise library of our own.

This is currently blocked by the fact that Unity currently does not have a SynchronizationContext for forcing code to run on the Unity main thread, which causes async tasks to default to being run on the Mono threadpool. This can easily cause issues with tasks calling Unity APIs from a thread other than the main thread.

james7132 commented 6 years ago

Unity seems to support calling these Tasks only within normal Unity game loops. We are currently using this to handle asynchronous processes outside of the normal context of Unity threads, which is preventing a UnitySynchronizationContext from being injected and causing Unity APIs to be called from non-main threads.

This issue is to be put on hold until a better solution for working with the new .NET 4.6 profile can be found. Currently builds fail or timeout on Unity Cloud Build with the setting enabled.

james7132 commented 6 years ago

Done with reimplementation.