Opc.Ua.Server.StandardServer.OnServerStopping C# (CSharp) Method

OnServerStopping() protected method

Called before the server stops
protected OnServerStopping ( ) : void
return void
        protected override void OnServerStopping()
        {
            // halt any outstanding timer.
            lock (m_registrationLock)
            {
                if (m_registrationTimer != null)
                {
                    m_registrationTimer.Dispose();
                    m_registrationTimer = null;
                }
            }

            // attempt graceful shutdown the server.
            try
            {
                if (m_maxRegistrationInterval > 0)
                {
                    // unregister from Discovery Server
                    m_registrationInfo.IsOnline = false;
                    RegisterWithDiscoveryServer();
                }

                lock (m_lock)
                {
                    if (m_serverInternal != null)
                    {
                        m_serverInternal.SubscriptionManager.Shutdown();
                        m_serverInternal.SessionManager.Shutdown();
                        m_serverInternal.NodeManager.Shutdown();
                    }
                }
            }
            catch (Exception e)
            {
                ServerError = new ServiceResult(e);   
            }
            finally
            {
                // ensure that everything is cleaned up.
                if (m_serverInternal != null)
                {
                    Utils.SilentDispose(m_serverInternal);
                    m_serverInternal = null;
                }
            }
        }