Exemple #1
0
        public void ListenWithQueue()
        {
            _process.Start();

            _tcpListener.Start();
            Console.WriteLine("Listen started on {0} ...", _tcpListener.LocalEndpoint);

            _queue = new DeleageQueueAsyncProcessor <Socket>(ConfigurationHelper.Instance.CountThreads,
                                                             MaxQueueSize, "Work thread", ProcessSocket);
            _queue.Start();

            Console.WriteLine("Socket queue started with # of threads: {0}", _queue.ThreadCount);

            try
            {
                while (true)
                {
                    var task = _tcpListener.AcceptSocketAsync();
                    task.Wait();
                    _queue.Add(task.Result);
                }
            }
            catch (Exception e)
            {
            }
        }
Exemple #2
0
 public override void Start()
 {
     if (_action != null)
     {
         if (_queue != null)
         {
             _queue.Dispose();
         }
         _queue = new DeleageQueueAsyncProcessor <T>(_countProcessors, _elementCounts, "", (obj, token) => _action(obj));
         _queue.Start();
     }
 }