private async void deleteTabToolStripMenuItem_Click(object sender, EventArgs e) { if (_tabPageClickIndex < 0 || _tabPageClickIndex >= tabControlNotepad.TabCount) { Log.Warning("Delete tab page could not find selected index: {_tabPageClickIndex}", _tabPageClickIndex); return; } if (_logicManager.PageCount == 1) { MessageBox.Show(this, "You must have atleast one tab page active", "Could not delete tab page", MessageBoxButtons.OK); return; } int tabIndex = tabControlNotepad.SelectedIndex; if (MessageBox.Show(this, $"Are you sure you want to delete this tab page with label: '{_logicManager.GetTabPageLabel(tabIndex)}' ?", "Confirm delete", MessageBoxButtons.OKCancel) == DialogResult.OK) { bool result = await _logicManager.RemoveTabPageAsync(tabIndex).ConfigureAwait(true); if (result) { _applicationState.TabPageAddOrRemove = true; UpdateTabControls(); } } }