/// <summary> /// <para>Launch the update process in background.</para> /// <para>When update process is finished (with error or not), the event AsyncUpdateFinished is raised with all the results for the calling application to exploit (e.g. if network error).</para> /// </summary> /// <param name="notificateNoUpdates">If false, do not show message box saying 'You already have the latest version'.</param> public void DoUpdateAsync() { try { if (!this.bgWorker.IsBusy) { this.bgWorker.RunWorkerAsync(this.applicationInfo); } else { MUpdateEventBridge.RaiseAsyncUpdateFinished(false, new Exception(lang.asyncAlreadyRunning)); } } catch (Exception ex) { MUpdateEventBridge.RaiseAsyncUpdateFinished(false, ex); } }
/// <summary> /// When bgWorker finished parsing dats from update.xml /// </summary> private void bgWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (!e.Cancelled && e.Error == null) // If no errors were reported { MUpdateXml update = (MUpdateXml)e.Result; // Gets the result sent as argument bool updated = CompareVersions(update, false); // Compare and finish MUpdateEventBridge.RaiseAsyncUpdateFinished(updated, (!updated && CheckedAlreadyUpToDate) ? new Exception(lang.latestVersionInstalled) : null); } else // If an error was reported { if (e.Error == null) { MUpdateEventBridge.RaiseAsyncUpdateFinished(false, new Exception(lang.checkError)); } else { MUpdateEventBridge.RaiseAsyncUpdateFinished(false, e.Error); } } }