private bool TestUpdateCancel() { bool result = false; TypedEventHandler <IPenClient, ProgressChangeEventArgs> firmwareInstallationStatusUpdated; TypedEventHandler <IPenClient, SimpleResultEventArgs> firmwareInstallationFinished; firmwareInstallationStatusUpdated = new TypedEventHandler <IPenClient, ProgressChangeEventArgs>((IPenClient sender, ProgressChangeEventArgs args) => { _controller.SuspendFirmwareInstallation(); }); _controller.FirmwareInstallationStatusUpdated += firmwareInstallationStatusUpdated; firmwareInstallationFinished = new TypedEventHandler <IPenClient, SimpleResultEventArgs>((IPenClient sender, SimpleResultEventArgs args) => { result = args.Result; _autoResetEvent.Set(); }); _controller.FirmwareInstallationFinished += firmwareInstallationFinished; Task.Factory.StartNew(async() => { StorageFile file = await KnownFolders.PicturesLibrary.GetFileAsync(FIRMWARE_FILENAME); _controller.RequestFirmwareInstallation(file, FIRMWARE_VERSION); }); _autoResetEvent.WaitOne(); _controller.FirmwareInstallationStatusUpdated -= firmwareInstallationStatusUpdated; _controller.FirmwareInstallationFinished -= firmwareInstallationFinished; return(!result); }