CNCGUI.MainForm.ClosePort C# (CSharp) Method

ClosePort() private method

private ClosePort ( ) : bool
return bool
        private bool ClosePort()
        {
            if (backgroundWorker.IsBusy)
            {
                if (MessageBox.Show("GCode send in progress. Cancel sending ?", "Attention", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.No)
                    return false;
                backgroundWorker.CancelAsync();
                while (backgroundWorker.IsBusy)
                {
                    Thread.Sleep(1000);
                }
            }
            return true;
        }