/// <summary> /// Stop scan button press /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ButtonStop_Click(object sender, EventArgs e) { // Cancel scanning if (cancellationSource != null) { cancellationSource.Cancel(); cancellationSource.Dispose(); } if (lidarTask != null) { lidarTask.GetAwaiter().GetResult(); } // Close port lidar.Close(); // Reset status texts labelSPC.Text = "-"; labelPPS.Text = "-"; // Allow starting again comboPort.Enabled = true; comboMode.Enabled = true; buttonStart.Enabled = true; buttonStop.Enabled = false; }