private void InitializeServerConnection()
        {
            try
            {
                /**** Packet processor mutex, loop and other support variables *************************/
                autoEventHostServer         = new AutoResetEvent(false); //the data mutex
                autoEvent2                  = new AutoResetEvent(false); //the FullPacket data mutex
                FullPacketDataProcessThread = new Thread(new ThreadStart(ProcessRecievedServerData));
                DataProcessHostServerThread = new Thread(new ThreadStart(NormalizeServerRawPackets));


                if (HostServerRawPackets == null)
                {
                    HostServerRawPackets = new MotherOfRawPackets(0);
                }
                else
                {
                    HostServerRawPackets.ClearList();
                }

                if (FullHostServerPacketList == null)
                {
                    FullHostServerPacketList = new Queue <FullPacket>();
                }
                else
                {
                    lock (FullHostServerPacketList)
                        FullHostServerPacketList.Clear();
                }
                /***************************************************************************************/


                FullPacketDataProcessThread.Start();
                DataProcessHostServerThread.Start();

                labelStatusInfo.Text      = "Connecting...";
                labelStatusInfo.ForeColor = System.Drawing.Color.Navy;
            }
            catch (Exception ex)
            {
                string exceptionMessage = (ex.InnerException != null) ? ex.InnerException.Message : ex.Message;
                Console.WriteLine($"EXCEPTION IN: InitializeServerConnection - {exceptionMessage}");
            }
        }
Exemple #2
0
        private void InitializeServerConnection()
        {
            try
            {
                autoEventHostServer         = new AutoResetEvent(false);
                autoEvent2                  = new AutoResetEvent(false);
                FullPacketDataProcessThread = new Thread(new ThreadStart(ProcessRecievedServerData));
                DataProcessHostServerThread = new Thread(new ThreadStart(NormalizeServerRawPackets));


                if (HostServerRawPackets == null)
                {
                    HostServerRawPackets = new MotherOfRawPackets(0);
                }
                else
                {
                    HostServerRawPackets.ClearList();
                }

                if (FullHostServerPacketList == null)
                {
                    FullHostServerPacketList = new Queue <FullPacket>();
                }
                else
                {
                    lock (FullHostServerPacketList)
                        FullHostServerPacketList.Clear();
                }

                FullPacketDataProcessThread.Start();
                DataProcessHostServerThread.Start();
            }
            catch (Exception ex)
            {
                Log.Message(ex.ToString());
            }
        }