1
0

TaskServices.Default.cs 1.1 KB

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