This source file includes following definitions.
- OnLaunched
- OnSuspending
#include "pch.h"
#include "MainPage.xaml.h"
#include "AdvancedCapture.xaml.h"
#include "Common\SuspensionManager.h"
using namespace SDKSample;
using namespace SDKSample::Common;
using namespace SDKSample::MediaCapture;
using namespace Concurrency;
using namespace Platform;
using namespace Windows::ApplicationModel;
using namespace Windows::ApplicationModel::Activation;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::UI::Core;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Controls::Primitives;
using namespace Windows::UI::Xaml::Data;
using namespace Windows::UI::Xaml::Input;
using namespace Windows::UI::Xaml::Interop;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;
App::App()
{
InitializeComponent();
this->Suspending += ref new SuspendingEventHandler(this, &SDKSample::App::OnSuspending);
}
void App::OnLaunched(LaunchActivatedEventArgs^ pArgs)
{
this->LaunchArgs = pArgs;
if (pArgs->PreviousExecutionState == ApplicationExecutionState::Running)
{
Window::Current->Activate();
return;
}
auto rootFrame = ref new Frame();
SuspensionManager::RegisterFrame(rootFrame, "AppFrame");
auto prerequisite = task<void>([](){});
if (pArgs->PreviousExecutionState == ApplicationExecutionState::Terminated)
{
prerequisite = SuspensionManager::RestoreAsync();
}
prerequisite.then([=]()
{
if (rootFrame->Content == nullptr)
{
if (!rootFrame->Navigate(TypeName(MainPage::typeid)))
{
throw ref new FailureException("Failed to create initial page");
}
}
Window::Current->Content = rootFrame;
Window::Current->Activate();
}, task_continuation_context::use_current());
}
void App::OnSuspending(Object^ sender, SuspendingEventArgs^ e)
{
(void) sender;
auto deferral = e->SuspendingOperation->GetDeferral();
SuspensionManager::SaveAsync().then([=]()
{
deferral->Complete();
});
}