TaskServices.Default.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
  2. using System.Threading;
  3. using System.Threading.Tasks;
  4. #if HAS_TPL46
  5. namespace System.Reactive.PlatformServices
  6. {
  7. //
  8. // WARNING: This code is kept *identically* in two places. One copy is kept in System.Reactive.Core for non-PLIB platforms.
  9. // Another copy is kept in System.Reactive.PlatformServices to enlighten the default lowest common denominator
  10. // behavior of Rx for PLIB when used on a more capable platform.
  11. //
  12. internal class DefaultTaskServices/*Impl*/ : ITaskServices
  13. {
  14. public bool TrySetCanceled<T>(TaskCompletionSource<T> tcs, CancellationToken token)
  15. {
  16. return tcs.TrySetCanceled(token);
  17. }
  18. }
  19. }
  20. #else
  21. namespace System.Reactive.PlatformServices
  22. {
  23. internal class DefaultTaskServices : ITaskServices
  24. {
  25. public bool TrySetCanceled<T>(TaskCompletionSource<T> tcs, CancellationToken token)
  26. {
  27. return tcs.TrySetCanceled();
  28. }
  29. }
  30. }
  31. #endif