HostLifecycleNotifications.Windows.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
  2. #if WINDOWS
  3. using Windows.ApplicationModel;
  4. using Windows.ApplicationModel.Core;
  5. namespace System.Reactive.PlatformServices
  6. {
  7. internal class HostLifecycleNotifications : IHostLifecycleNotifications
  8. {
  9. private EventHandler<SuspendingEventArgs> _suspending;
  10. private EventHandler<object> _resuming;
  11. public event EventHandler<HostSuspendingEventArgs> Suspending
  12. {
  13. add
  14. {
  15. _suspending = (o, e) => value(o, new HostSuspendingEventArgs());
  16. CoreApplication.Suspending += _suspending;
  17. }
  18. remove
  19. {
  20. CoreApplication.Suspending -= _suspending;
  21. }
  22. }
  23. public event EventHandler<HostResumingEventArgs> Resuming
  24. {
  25. add
  26. {
  27. _resuming = (o, e) => value(o, new HostResumingEventArgs());
  28. CoreApplication.Resuming += _resuming;
  29. }
  30. remove
  31. {
  32. CoreApplication.Resuming -= _resuming;
  33. }
  34. }
  35. }
  36. }
  37. #endif