/// <summary> /// Run the packet on the given (already started) device. /// </summary> private void RunOnStartedDevice(IDevice device) { // Set state stateUpdate(LauncherStates.Deploying, string.Empty); // Prepare debug launcher Launcher.PrepareForLaunch(); // Install package if (IsCancelled) return; var deployer = new BarDeployer(device); deployer.Logger += LogLine; LogLine(string.Format("----- Installing {0}", barPath)); deployer.Install(barPath, false); LogLine(string.Format("----- Installed {0}", barPath)); // Prepare for debugger attachment (if debuggable) if (IsCancelled) return; if (debuggable) { Launcher.StartLaunchMonitor(ide, device, barPath, packageName, 17/*minSdkVersion TODO */, launchFlags, stateUpdate, cancellationTokenSource.Token); } // Run activity if (IsCancelled) return; stateUpdate(LauncherStates.Starting, string.Empty); LogLine(string.Format("----- Starting activity {0}", activity)); deployer.LaunchFile(barPath); LogLine(string.Format("----- Started activity {0}", activity)); stateUpdate(LauncherStates.Started, string.Empty); }
/// <summary> /// Run the deployer in a background task. /// </summary> private void RunDeployer(Action<BarDeployLib.BarDeployer> action) { treeView.Nodes.Clear(); var device = BlackBerryDevices.Instance.DefaultDevice; var deployer = new BarDeployer(device) { Logger = LogResults }; Enabled = false; var ui = TaskScheduler.FromCurrentSynchronizationContext(); Task.Factory.StartNew(() => { try { action(deployer); } catch (Exception ex) { LogResults("Failure: " + ex.Message); } }).ContinueWith(t => { Enabled = true; }, ui); }