private void stopButton_Click(object sender, EventArgs e) { logger.Debug("stopButton_Click(...) "); mainForm.Cursor = Cursors.WaitCursor; this.Enabled = false; Task.Run(() => { StopStreaming(); }).ContinueWith(t => { //logger.Info(SharpDX.Diagnostics.ObjectTracker.ReportActiveObjects()); UpdateControls(); mainForm.Cursor = Cursors.Default; this.Enabled = true; if (statisticForm != null) { statisticForm.Stop(); statisticForm.Visible = false; } if (previewForm != null && !previewForm.IsDisposed) { previewForm.Close(); previewForm = null; } regionForm?.Close(); regionForm = null; var ex = t.Exception; if (ex != null) { var iex = ex.InnerException; MessageBox.Show(iex.Message); } else { } }, TaskScheduler.FromCurrentSynchronizationContext()); }
private void OnStreamStopped() { infoButton.Enabled = true; networkSettingsLayoutPanel.Enabled = true; videoSourceSettingsLayoutPanel.Enabled = true; audioSourceSettingsLayoutPanel.Enabled = true; switchStreamingStateButton.Enabled = true; switchStreamingStateButton.Text = "Start Streaming"; startToolStripMenuItem.Text = "Start"; contextMenu.Enabled = true; captureStatusLabel.Text = "Ready to stream"; captureStatusDescriptionLabel.Text = ""; this.Cursor = Cursors.Default; if (statisticForm != null) { statisticForm.Stop(); statisticForm.Visible = false; } if (debugBorderForm != null) { debugBorderForm.Close(); debugBorderForm = null; } if (selectAreaForm != null) { selectAreaForm.Capturing = false; } var errorMessage = ""; var ex = mediaStreamer.ExceptionObj; if (ex != null) { errorMessage = ex.Message; var iex = ex.InnerException; if (iex != null) { errorMessage = iex.Message; } } if (mediaStreamer != null) { mediaStreamer.Shutdown(); } if (!string.IsNullOrEmpty(errorMessage)) { MessageBox.Show(errorMessage); } }