Skip to content
This repository has been archived by the owner on Jan 14, 2022. It is now read-only.

Commit

Permalink
Progress bar in the app and outside app is now the same in Creators u…
Browse files Browse the repository at this point in the history
…pdate and higher
  • Loading branch information
colinkiama committed Mar 6, 2018
1 parent be724b5 commit fa5ade0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
14 changes: 13 additions & 1 deletion UWPPackageInstaller/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ private async void showProgressInNotification()
ApplicationTrigger appTrigger = new ApplicationTrigger();
var backgroundTask = RegisterBackgroundTask("installTask.install", "installTask", appTrigger);
//backgroundTask.Completed += new BackgroundTaskCompletedEventHandler(OnCompleted);
//backgroundTask.Progress += new BackgroundTaskProgressEventHandler(OnProgress);
backgroundTask.Progress += new BackgroundTaskProgressEventHandler(OnProgress);
var result = await appTrigger.RequestAsync(thingsToPassOver);

foreach (var task in BackgroundTaskRegistration.AllTasks)
Expand All @@ -233,6 +233,18 @@ private async void showProgressInNotification()

}
}
installProgressBar.Visibility = Visibility.Visible;
installValueTextBlock.Visibility = Visibility.Visible;
}

private async void OnProgress(BackgroundTaskRegistration sender, BackgroundTaskProgressEventArgs args)
{
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
{
installProgressBar.Value = args.Progress;
installValueTextBlock.Text = $"{args.Progress}%";
});
}

private void AttachCompletedHandler(IBackgroundTaskRegistration task)
Expand Down
10 changes: 6 additions & 4 deletions installTask/install.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ public sealed class install : IBackgroundTask
BackgroundTaskDeferral _deferral;
string resultText = "Nothing";
bool pkgRegistered = false;

private static IBackgroundTaskInstance boom;
static double installPercentage = 0;
/// <summary>
/// Pretty much identical to showProgressInApp() in MainPage.xaml.cs
/// </summary>
/// <param name="taskInstance"></param>
public async void Run(IBackgroundTaskInstance taskInstance)
{

boom = taskInstance;
_deferral = taskInstance.GetDeferral();
ApplicationTriggerDetails details = (ApplicationTriggerDetails)taskInstance.TriggerDetails;
string packagePath = "";
Expand Down Expand Up @@ -83,9 +84,10 @@ public async void Run(IBackgroundTaskInstance taskInstance)
}


private void installProgress(DeploymentProgress installProgress)
private static void installProgress(DeploymentProgress installProgress)
{
double installPercentage = installProgress.percentage;
installPercentage = installProgress.percentage;
boom.Progress = (uint)installPercentage;
notification.UpdateProgress(installPercentage);
}

Expand Down

0 comments on commit fa5ade0

Please sign in to comment.