/// <summary> /// Perform the server update. /// </summary> private void PerformUpdate() { try { Log.Write("Update is available"); _server.Update(); } catch (Exception ex) { Log.Write(ex); } }
/// <summary> /// Runs the Plex Media Server update. /// </summary> public void Run() { try { Log.Write("Checking for server update."); if (server.IsUpdateAvailable()) { Log.Write("Update is available"); server.Update(); } else { Log.Write("No update is available. Exiting."); } } catch (Exception ex) { Log.Write(ex); } }
/// <summary> /// Perform the server update. /// </summary> private void PerformUpdate() { try { btnUpdate.Enabled = false; btnCancel.Visible = false; btnExit.Enabled = false; if (_cts == null) { _cts = new CancellationTokenSource(); } CancellationToken ct = _cts.Token; Task plexUpdate = Task.Factory.StartNew(() => { // Throw an exception if already cancelled ct.ThrowIfCancellationRequested(); _server.Update(); }, _cts.Token); plexUpdate.Wait(); if (!_server.IsRunning()) { Log.Write("The Plex server was not started successfully."); } } catch (Exception ex) { txtUpdateStatus.Text += $"ERROR: {ex.Message}{NewLine}"; Log.Write(ex); } finally { _cts?.Dispose(); Initialize(); } }
/// <summary> /// Performs the Plex Media Server update. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// Event-related arguments. /// </param> void BtnUpdateClick(object sender, EventArgs e) { try { btnUpdate.Enabled = false; btnCancel.Visible = false; btnExit.Enabled = false; if (cts == null) { cts = new CancellationTokenSource(); } CancellationToken ct = cts.Token; Task plexUpdate = Task.Factory.StartNew(() => { // Throw an exception if already cancelled ct.ThrowIfCancellationRequested(); server.Update(); }, cts.Token); plexUpdate.Wait(); } catch (Exception ex) { txtUpdateStatus.Text += $"ERROR: {ex.Message}{NewLine}"; Log.Write(ex); } finally { if (cts != null) { cts.Dispose(); } Initialize(); } }