Skip to content

Instantly share code, notes, and snippets.

@kirkshoop
Created September 6, 2013 05:37
Show Gist options
  • Save kirkshoop/6459935 to your computer and use it in GitHub Desktop.
Save kirkshoop/6459935 to your computer and use it in GitHub Desktop.
Reactive code to handle the suspending event and save the state.
auto ct = std::make_shared<rx::CurrentThreadScheduler>();
typedef rxrt::EventPattern<Platform::Object^, SuspendingEventArgs^> SuspendingEventPattern;
rx::from(suspending)
.chain<rxrt::defer_operation>(
[](SuspendingEventPattern ep)
{
// defer this operation
return ep.EventArgs()->SuspendingOperation;
},
[](rxrt::OperationPattern<SuspendingOperation^>, SuspendingEventPattern)
{
// do this while the operation is deferred
return SuspensionManager::ReactiveSave();
},
ct)
.publish()
.connect_forever();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment