Closed NN--- closed 3 years ago
Because TaskEx is from the Async CTP, and it does not have FromCanceled in Microsoft version.
Now that you mention it, I should review the targets where you can have TaskEx from Microsoft.
I guess I can extend TaskEx to include FromResult.
Regardless TaskExEx is there for those platforms where you can get both Taks and TaskEx from Microsoft (and we don't want to conflict with Microsoft), and FromResult is missing in that case, so you get it from TaskExEx.
Notice TaskExEx does not have conditional compilation, it is always there.
Ok. As usual MS make everything more complicated :)
Currently due to lack of FromResult in TaskEx I have two conditionals, for TaskEx and for TaskExEx instead of having only one.
You should be able to get both FromCanceled and FromResult from TaskExEx always,
https://github.com/theraot/Theraot/blob/master/Framework.Core/System/Threading/Tasks/TaskExEx.fromcanceled.cs https://github.com/theraot/Theraot/blob/master/Framework.Core/System/Threading/Tasks/TaskExEx.fromresult.cs
If that does not work, then I need to fix that.
I understand, what I do is the following to make usage of types from CLR as much as possible.
#if NET45_OR_GREATER || TARGETS_NETSTANDARD || TARGETS_NETCOREAPP
using TaskEx = System.Threading.Tasks.Task;
#else
using TaskEx = System.Threading.Tasks.TaskEx;
#endif
#if NET46_OR_GREATER || NETSTANDARD13_OR_GREATER || TARGETS_NETCOREAPP
using TaskExEx = System.Threading.Tasks.Task;
#else
using TaskExEx = System.Threading.Tasks.TaskExEx;
#endif
I see,
I guess these tend to accumulate.
That makes me wish you could do it in a single place. Some sort of global type alias or typedef. TypeForwardedToAttribute comes to mind, but, it is not the same thing.
One day there will global type alias.
Is it by design ?
public static partial class TaskExEx
Why there is TaskEx.FromResult https://github.com/theraot/Theraot/blob/master/Framework.Core/System/Threading/Tasks/TaskEx.cs But there is no TaskEx.FromCancelled.