The following is an example of using IAsyncOperationWithProgress to display the installation process of an XAP file programmatically. I'm new to Win8 development, so I'm not sure if it is completely idiomatic.
Check out Dispatcher.BeginInvoke to marshal progress back into the UI thread. Hope this helps:
private async void InstallApp(string name, Uri uri) { try { StatusTextBlock.Text = "Installing app"; var installTask = InstallationManager.AddPackageAsync(name, uri); installTask.Progress = (installResult, progress) => Dispatcher.BeginInvoke(() => { StatusTextBlock.Text = "Progress: " + progress; }); var result = await installTask; StatusTextBlock.Text = "Done: " + result.InstallState.ToString(); } catch (Exception ex) { StatusTextBlock.Text = "Failed to install: " + ex.Message; } }
Lee richardson
source share