Opc.Ua.Sample.Controls.ClientForm.OnClosing C# (CSharp) Method

OnClosing() protected method

Disconnect from the server if ths form is closing.
protected OnClosing ( CancelEventArgs e ) : void
e CancelEventArgs
return void
        protected override void OnClosing(CancelEventArgs e)
        {
            if (m_masterForm == null && m_forms.Count > 0)
            {
                if (MessageBox.Show("Close all sessions?", "Close Window", MessageBoxButtons.YesNo) != DialogResult.Yes)
                {
                    e.Cancel = true;
                    return;
                }

                List<ClientForm> forms = new List<ClientForm>(m_forms);

                foreach (ClientForm form in forms)
                {
                    form.Close();
                }
            }

            Disconnect();
        }