ACR_ServerCommunicator.ACR_ServerCommunicator.DispatchPeriodicEvents C# (CSharp) Method

DispatchPeriodicEvents() public method

Called to periodically dispatch events on the main thread.
public DispatchPeriodicEvents ( ) : void
return void
        public void DispatchPeriodicEvents()
        {
            try
            {
                DrainCommandQueue();
            }
            catch (Exception e)
            {
                WriteTimestampedLogEntry(String.Format("ACR_ServerCommunicator.DispatchPeriodicEvents(): Encountered exception: {0}", e));
            }

            try
            {
                RunUpdateServerExternalAddress();
            }
            catch (Exception e)
            {
                WriteTimestampedLogEntry(String.Format("ACR_ServerCommunicator.DispatchPeriodicEvents(): Encountered exception in external address update: {0}", e));
            }

            //
            // GetExtendedUdpTable appears to be unreliable under some
            // conditions, hitting a problem in the network stack.  If the
            // socket I/O subsystem has obtained the local port, use it from
            // there in case the standard mechanism to auto detect it failed.
            //

            if ((GetGlobalInt("ACR_SERVERLISTENER_PORT") == 0) &&
                (SocketIo.ServerUdpListenerPort != 0))
            {
                SetGlobalInt("ACR_SERVERLISTENER_PORT", SocketIo.ServerUdpListenerPort);
                SetGlobalInt("ACR_SERVERLISTENER_ADDRESS", SocketIo.ServerUdpListenerAddress);
                WriteTimestampedLogEntry(String.Format("ACR_ServerCommunicator.DispatchPeriodicEvents(): Detected server data port as {0}.", SocketIo.ServerUdpListenerPort));

                try
                {
                    UpdateServerExternalAddress();
                }
                catch (Exception e)
                {
                    WriteTimestampedLogEntry(String.Format("ACR_ServerCommunicator.DispatchPeriodicEvents(): Encountered exception in external address update: {0}", e));
                }
            }

            //
            // Flush any queued log messages to the server log file.
            //

            ALFA.Shared.Logger.FlushLogMessages(this);
        }
ACR_ServerCommunicator