Exemplo n.º 1
0
        /// <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();
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Gets the value indicating that the Plex server is running.
 /// </summary>
 /// <returns>
 /// True if the Plex server is running, false if the server is not
 /// running.
 /// </returns>
 public bool IsPlexRunning()
 {
     return(_server.IsRunning());
 }