/// <summary> /// Closing. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void InstantMessage_FormClosing(object sender, FormClosingEventArgs e) { // Ask to save the message first. DialogResult result = MessageBox.Show("Save the messages first?", "Instant Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { // Do not close the window. e.Cancel = true; } else { try { // Cleanup the player. if (_player != null) { _player.Stop(); _player.Dispose(); } } catch { } // Send the form closing event. OnInstantMessageClosing?.Invoke(this, new EventArgs()); } }
/// <summary> /// Closing. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void InstantMessage_FormClosing(object sender, FormClosingEventArgs e) { try { // Cleanup the player. if (_player != null) { _player.Stop(); _player.Dispose(); } } catch { } // Send the form closing event. OnInstantMessageClosing?.Invoke(this, new EventArgs()); }