Skip to content

Commit

Permalink
Windows 10 RTM Release - May 2016 Update
Browse files Browse the repository at this point in the history
  • Loading branch information
oldnewthing committed May 19, 2016
1 parent 2d839d3 commit 6b62567
Show file tree
Hide file tree
Showing 90 changed files with 2,338 additions and 2,349 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ ipch/
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb

# Visual Studio profiler
*.psess
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Array<Scenario>^ MainPage::scenariosInner = ref new Array<Scenario>
{
// The format here is the following:
// { "Description for the sample", "Fully quaified name for the class that implements the scenario" }
{ "Background task", "SDKTemplate.SampleBackgroundTask" },
{ "Background task", "SDKTemplate.SampleBackgroundTask" },
{ "Background task with a condition", "SDKTemplate.SampleBackgroundTaskWithCondition" },
{ "Servicing complete task", "SDKTemplate.ServicingCompleteTask" },
{ "Background task with time trigger", "SDKTemplate.TimeTriggeredTask" },
Expand Down Expand Up @@ -102,7 +102,7 @@ BackgroundTaskRegistration^ BackgroundTaskSample::RegisterBackgroundTask(String^

auto task = builder->Register();

UpdateBackgroundTaskStatus(name, true);
UpdateBackgroundTaskRegistrationStatus(name, true);

//
// Remove previous completion status from local settings.
Expand Down Expand Up @@ -142,17 +142,17 @@ void BackgroundTaskSample::UnregisterBackgroundTasks(String^ name)
{
auto cur = iter->Current->Value;

if(cur->Name == name)
if (cur->Name == name)
{
cur->Unregister(true);
UpdateBackgroundTaskStatus(name, false);
UpdateBackgroundTaskRegistrationStatus(name, false);
}

hascur = iter->MoveNext();
}
}

void BackgroundTaskSample::UpdateBackgroundTaskStatus(String^ name, bool registered)
void BackgroundTaskSample::UpdateBackgroundTaskRegistrationStatus(String^ name, bool registered)
{
if (name == SampleBackgroundTaskName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace SDKTemplate
static BackgroundTaskRegistration^ RegisterBackgroundTask(String^ taskEntryPoint, String^ name, IBackgroundTrigger^ trigger, IBackgroundCondition^ condition);
static bool TaskRequiresBackgroundAccess(String^ name);
static void UnregisterBackgroundTasks(String^ name);
static void UpdateBackgroundTaskStatus(String^ name, bool registered);
static void UpdateBackgroundTaskRegistrationStatus(String^ name, bool registered);

static String^ SampleBackgroundTaskProgress;
static bool SampleBackgroundTaskRegistered;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,15 @@ void SampleBackgroundTask::OnNavigatedTo(NavigationEventArgs^ e)
//
// Attach progress and completed handlers to any existing tasks.
//
auto iter = BackgroundTaskRegistration::AllTasks->First();
auto hascur = iter->HasCurrent;
while (hascur)
for (auto pair : BackgroundTaskRegistration::AllTasks)
{
auto cur = iter->Current->Value;

if (cur->Name == SampleBackgroundTaskName)
auto task = pair->Value;
if (task->Name == SampleBackgroundTaskName)
{
BackgroundTaskSample::UpdateBackgroundTaskStatus(cur->Name, true);
AttachProgressAndCompletedHandlers(cur);
BackgroundTaskSample::UpdateBackgroundTaskRegistrationStatus(task->Name, true);
AttachProgressAndCompletedHandlers(task);
break;
}

hascur = iter->MoveNext();
}

UpdateUI();
Expand All @@ -69,19 +64,8 @@ void SampleBackgroundTask::OnNavigatedTo(NavigationEventArgs^ e)
/// <param name="task">The task to attach progress and completed handlers to.</param>
void SampleBackgroundTask::AttachProgressAndCompletedHandlers(IBackgroundTaskRegistration^ task)
{
auto progress = [this](BackgroundTaskRegistration^ task, BackgroundTaskProgressEventArgs^ args)
{
auto progress = "Progress: " + args->Progress + "%";
BackgroundTaskSample::SampleBackgroundTaskProgress = progress;
UpdateUI();
};
task->Progress += ref new BackgroundTaskProgressEventHandler(progress);

auto completed = [this](BackgroundTaskRegistration^ task, BackgroundTaskCompletedEventArgs^ args)
{
UpdateUI();
};
task->Completed += ref new BackgroundTaskCompletedEventHandler(completed);
task->Progress += ref new BackgroundTaskProgressEventHandler(this, &SampleBackgroundTask::OnProgress);
task->Completed += ref new BackgroundTaskCompletedEventHandler(this, &SampleBackgroundTask::OnCompleted);
}

/// <summary>
Expand Down Expand Up @@ -110,6 +94,31 @@ void SampleBackgroundTask::UnregisterBackgroundTask(Platform::Object^ sender, Wi
UpdateUI();
}

/// <summary>
/// Handle background task progress.
/// </summary>
/// <param name="task">The task that is reporting progress.</param>
/// <param name="args">Arguments of the progress report.</param>
void SampleBackgroundTask::OnProgress(BackgroundTaskRegistration^ task, BackgroundTaskProgressEventArgs^ args)
{
Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([this, args]()
{
auto progress = "Progress: " + args->Progress + "%";
BackgroundTaskSample::SampleBackgroundTaskProgress = progress;
UpdateUI();
}));
}

/// <summary>
/// Handle background task completion.
/// </summary>
/// <param name="task">The task that is reporting completion.</param>
/// <param name="args">Arguments of the completion report.</param>
void SampleBackgroundTask::OnCompleted(BackgroundTaskRegistration^ task, BackgroundTaskCompletedEventArgs^ args)
{
UpdateUI();
}

/// <summary>
/// Update the scenario UI.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ namespace SDKTemplate
void AttachProgressAndCompletedHandlers(Windows::ApplicationModel::Background::IBackgroundTaskRegistration^ task);
void RegisterBackgroundTask(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void UnregisterBackgroundTask(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void OnProgress(Windows::ApplicationModel::Background::BackgroundTaskRegistration^ task, Windows::ApplicationModel::Background::BackgroundTaskProgressEventArgs^ args);
void OnCompleted(Windows::ApplicationModel::Background::BackgroundTaskRegistration^ task, Windows::ApplicationModel::Background::BackgroundTaskCompletedEventArgs^ args);
void UpdateUI();
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,15 @@ void SampleBackgroundTaskWithCondition::OnNavigatedTo(NavigationEventArgs^ e)
//
// Attach progress and completed handlers to any existing tasks.
//
auto iter = BackgroundTaskRegistration::AllTasks->First();
auto hascur = iter->HasCurrent;
while (hascur)
for (auto pair : BackgroundTaskRegistration::AllTasks)
{
auto cur = iter->Current->Value;

if (cur->Name == SampleBackgroundTaskWithConditionName)
auto task = pair->Value;
if (task->Name == SampleBackgroundTaskWithConditionName)
{
BackgroundTaskSample::UpdateBackgroundTaskStatus(cur->Name, true);
AttachProgressAndCompletedHandlers(cur);
BackgroundTaskSample::UpdateBackgroundTaskRegistrationStatus(task->Name, true);
AttachProgressAndCompletedHandlers(task);
break;
}

hascur = iter->MoveNext();
}

UpdateUI();
Expand All @@ -69,19 +64,8 @@ void SampleBackgroundTaskWithCondition::OnNavigatedTo(NavigationEventArgs^ e)
/// <param name="task">The task to attach progress and completed handlers to.</param>
void SampleBackgroundTaskWithCondition::AttachProgressAndCompletedHandlers(IBackgroundTaskRegistration^ task)
{
auto progress = [this](BackgroundTaskRegistration^ task, BackgroundTaskProgressEventArgs^ args)
{
auto progress = "Progress: " + args->Progress + "%";
BackgroundTaskSample::SampleBackgroundTaskWithConditionProgress = progress;
UpdateUI();
};
task->Progress += ref new BackgroundTaskProgressEventHandler(progress);

auto completed = [this](BackgroundTaskRegistration^ task, BackgroundTaskCompletedEventArgs^ args)
{
UpdateUI();
};
task->Completed += ref new BackgroundTaskCompletedEventHandler(completed);
task->Progress += ref new BackgroundTaskProgressEventHandler(this, &SampleBackgroundTaskWithCondition::OnProgress);
task->Completed += ref new BackgroundTaskCompletedEventHandler(this, &SampleBackgroundTaskWithCondition::OnCompleted);
}

/// <summary>
Expand Down Expand Up @@ -110,6 +94,31 @@ void SampleBackgroundTaskWithCondition::UnregisterBackgroundTask(Platform::Objec
UpdateUI();
}

/// <summary>
/// Handle background task progress.
/// </summary>
/// <param name="task">The task that is reporting progress.</param>
/// <param name="args">Arguments of the progress report.</param>
void SampleBackgroundTaskWithCondition::OnProgress(BackgroundTaskRegistration^ task, BackgroundTaskProgressEventArgs^ args)
{
Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([this, args]()
{
auto progress = "Progress: " + args->Progress + "%";
BackgroundTaskSample::SampleBackgroundTaskWithConditionProgress = progress;
UpdateUI();
}));
}

/// <summary>
/// Handle background task completion.
/// </summary>
/// <param name="task">The task that is reporting completion.</param>
/// <param name="args">Arguments of the completion report.</param>
void SampleBackgroundTaskWithCondition::OnCompleted(BackgroundTaskRegistration^ task, BackgroundTaskCompletedEventArgs^ args)
{
UpdateUI();
}

/// <summary>
/// Update the scenario UI.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ namespace SDKTemplate
void AttachProgressAndCompletedHandlers(Windows::ApplicationModel::Background::IBackgroundTaskRegistration^ task);
void RegisterBackgroundTask(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void UnregisterBackgroundTask(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void OnProgress(Windows::ApplicationModel::Background::BackgroundTaskRegistration^ task, Windows::ApplicationModel::Background::BackgroundTaskProgressEventArgs^ args);
void OnCompleted(Windows::ApplicationModel::Background::BackgroundTaskRegistration^ task, Windows::ApplicationModel::Background::BackgroundTaskCompletedEventArgs^ args);
void UpdateUI();
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,15 @@ void ServicingCompleteTask::OnNavigatedTo(NavigationEventArgs^ e)
//
// Attach progress and completed handlers to any existing tasks.
//
auto iter = BackgroundTaskRegistration::AllTasks->First();
auto hascur = iter->HasCurrent;
while (hascur)
for (auto pair : BackgroundTaskRegistration::AllTasks)
{
auto cur = iter->Current->Value;

if (cur->Name == ServicingCompleteTaskName)
auto task = pair->Value;
if (task->Name == ServicingCompleteTaskName)
{
BackgroundTaskSample::UpdateBackgroundTaskStatus(cur->Name, true);
AttachProgressAndCompletedHandlers(cur);
BackgroundTaskSample::UpdateBackgroundTaskRegistrationStatus(task->Name, true);
AttachProgressAndCompletedHandlers(task);
break;
}

hascur = iter->MoveNext();
}

UpdateUI();
Expand All @@ -69,19 +64,8 @@ void ServicingCompleteTask::OnNavigatedTo(NavigationEventArgs^ e)
/// <param name="task">The task to attach progress and completed handlers to.</param>
void ServicingCompleteTask::AttachProgressAndCompletedHandlers(IBackgroundTaskRegistration^ task)
{
auto progress = [this](BackgroundTaskRegistration^ task, BackgroundTaskProgressEventArgs^ args)
{
auto progress = "Progress: " + args->Progress + "%";
BackgroundTaskSample::ServicingCompleteTaskProgress = progress;
UpdateUI();
};
task->Progress += ref new BackgroundTaskProgressEventHandler(progress);

auto completed = [this](BackgroundTaskRegistration^ task, BackgroundTaskCompletedEventArgs^ args)
{
UpdateUI();
};
task->Completed += ref new BackgroundTaskCompletedEventHandler(completed);
task->Progress += ref new BackgroundTaskProgressEventHandler(this, &ServicingCompleteTask::OnProgress);
task->Completed += ref new BackgroundTaskCompletedEventHandler(this, &ServicingCompleteTask::OnCompleted);
}

/// <summary>
Expand Down Expand Up @@ -111,6 +95,31 @@ void ServicingCompleteTask::UnregisterBackgroundTask(Platform::Object^ sender, W
UpdateUI();
}

/// <summary>
/// Handle background task progress.
/// </summary>
/// <param name="task">The task that is reporting progress.</param>
/// <param name="args">Arguments of the progress report.</param>
void ServicingCompleteTask::OnProgress(BackgroundTaskRegistration^ task, BackgroundTaskProgressEventArgs^ args)
{
Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([this, args]()
{
auto progress = "Progress: " + args->Progress + "%";
BackgroundTaskSample::ServicingCompleteTaskProgress = progress;
UpdateUI();
}));
}

/// <summary>
/// Handle background task completion.
/// </summary>
/// <param name="task">The task that is reporting completion.</param>
/// <param name="args">Arguments of the completion report.</param>
void ServicingCompleteTask::OnCompleted(BackgroundTaskRegistration^ task, BackgroundTaskCompletedEventArgs^ args)
{
UpdateUI();
}

/// <summary>
/// Update the scenario UI.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ namespace SDKTemplate
void AttachProgressAndCompletedHandlers(Windows::ApplicationModel::Background::IBackgroundTaskRegistration^ task);
void RegisterBackgroundTask(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void UnregisterBackgroundTask(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void OnProgress(Windows::ApplicationModel::Background::BackgroundTaskRegistration^ task, Windows::ApplicationModel::Background::BackgroundTaskProgressEventArgs^ args);
void OnCompleted(Windows::ApplicationModel::Background::BackgroundTaskRegistration^ task, Windows::ApplicationModel::Background::BackgroundTaskCompletedEventArgs^ args);
void UpdateUI();
};
}
Loading

0 comments on commit 6b62567

Please sign in to comment.