public void UpdateCallback(Object threadContext) { if (this._doneUninstallEvent != null) #region "UNINSTALL" { // 1. Kill Process try { if (this.CurrentPID != 0) { MyProcess.KillProcess(this.CurrentPID); // Already Found. } MyProcess.KillProcess(this.Name); // With Extension MyProcess.KillProcess(System.IO.Path.GetFileNameWithoutExtension(this.Name)); // Without Extension } catch (Exception ex) { GotError(ex.ToString()); } Thread.Sleep(2000); //if (ProductCode == null) { // 2. Delete that file. try { System.IO.File.Delete(System.IO.Path.Combine(UpdatePath, this.Name)); } catch (Exception ex) { GotError(ex.ToString()); } } #region "#TODO: Product Code" /* * else * { * // 2. Uninstall current package. * // msiexec /x {1239081203801283012312-1230812038-1230} /passive * //CNU.RunAs.by.User("msiexec /x " + ProductCode); * } */ #endregion _doneUninstallEvent.Set(); } #endregion if (this._doneInstallEvent != null) #region "INSTALL" { //if (ProductCode == null) { // 1. Download Update -> Done. // e) If Download Fail, delete that file. try { String remotePath = Package.UpdateServer + this.Name + "/" + this.Version + "/" + this.Name; String localPath = System.IO.Path.Combine(UpdatePath, "Updates", this.Name); System.IO.Directory.CreateDirectory(System.IO.Path.Combine(UpdatePath, "Updates")); WebClient newClient = new WebClient(); newClient.DownloadFile(remotePath, localPath); } catch (Exception ex) { GotError(ex.ToString()); } } #region "#TODO: Product Code" /* * else * { * // 1. Download Update * // 2. Kill Process * // 3. Install latest package. * // setup.msi /passive * } */ #endregion _doneInstallEvent.Set(); } #endregion return; }