HostLifecycleNotifications.Windows.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the Apache 2.0 License.
  3. // See the LICENSE file in the project root for more information.
  4. #if WINDOWS
  5. using Windows.ApplicationModel;
  6. using Windows.ApplicationModel.Core;
  7. namespace System.Reactive.PlatformServices
  8. {
  9. internal class HostLifecycleNotifications : IHostLifecycleNotifications
  10. {
  11. private EventHandler<SuspendingEventArgs> _suspending;
  12. private EventHandler<object> _resuming;
  13. public event EventHandler<HostSuspendingEventArgs> Suspending
  14. {
  15. add
  16. {
  17. _suspending = (o, e) => value(o, new HostSuspendingEventArgs());
  18. CoreApplication.Suspending += _suspending;
  19. }
  20. remove
  21. {
  22. CoreApplication.Suspending -= _suspending;
  23. }
  24. }
  25. public event EventHandler<HostResumingEventArgs> Resuming
  26. {
  27. add
  28. {
  29. _resuming = (o, e) => value(o, new HostResumingEventArgs());
  30. CoreApplication.Resuming += _resuming;
  31. }
  32. remove
  33. {
  34. CoreApplication.Resuming -= _resuming;
  35. }
  36. }
  37. }
  38. }
  39. #endif