Beispiel #1
0
        public static int Main(String[] args)
        {
            bool closeServer = false;
            //Making queues and dictionary to pass to producer and consumer
            Queue <Message>  queue      = new Queue <Message>();
            SyncEvents       syncEvents = new SyncEvents();
            PlayerDictionary dictonary  = new PlayerDictionary();

            producer = new Producer(queue, syncEvents);

            Console.WriteLine("Configuring worker threads...");
            Consumer consumer       = new Consumer(queue, syncEvents, dictonary);
            Thread   consumerThread = new Thread(consumer.ThreadRun);

            Console.WriteLine("Launching producer and consumer threads");
            consumerThread.Start();
            //Load threads to launch recieve callbacks on
            Thread TCP_Thread;
            Thread UDP_Thread;

            TCP_Thread = new Thread(new ThreadStart(TCP_StartListening));
            UDP_Thread = new Thread(new ThreadStart(UDP_StartListening));

            TCP_Thread.Start();
            UDP_Thread.Start();

            while (!closeServer)
            {
            }
            Console.WriteLine("Signaling threads to terminate...");
            syncEvents.ExitThreadEvent.Set();

            consumerThread.Join();
            return(0);
        }
Beispiel #2
0
 public Consumer(Queue <Message> q, SyncEvents e, PlayerDictionary d)
 {
     _queue        = q;
     _syncEvents   = e;
     _myDictionary = d;
 }