Exemple #1
0
        public bool AddResponseToIncomingQueue(GHResponseFromClient response)
        {
            bool append_success = false;

            lock (_inComingClientResponseQueueLock)
            {
                for (int i = 0; i < 20; i++)
                {
                    if (!_updatingInComingClientResponseQueue)
                    {
                        _updatingInComingClientResponseQueue = true;
                        _inComingClientResponseQueue.Append(response);
                        append_success = true;
                        _updatingInComingClientResponseQueue = false;
                        break;
                    }
                    else
                    {
                        Thread.Sleep(5);
                        Debug.WriteLine("AddResponseToIncomingQueue: Trying Again - Count: " + i);
                    }
                }

                if (append_success)
                {
                    Debug.WriteLine("AddResponseToIncomingQueue Successful");
                }
                else
                {
                    Debug.WriteLine("AddResponseToIncomingQueue Failed!");
                }
            }
            return(append_success);
        }
Exemple #2
0
 public void Append(string filePath, string content)
 {
     _writeQueue.Append(new WriteQueueItem()
     {
         filePath = filePath,
         content  = content,
         fileMode = FileMode.Append
     });
 }
Exemple #3
0
        public void Listen(CancellationToken cancel)
        {
            // TODO: [vermorel] Use a 'ConnectionId' instead.
            cancel.Register(() => _listener.Close());
            while (!cancel.IsCancellationRequested)
            {
                try
                {
                    var s = _listener.Accept();
                    _queue.Append(new ClientConnection(s, ClientId.Next(), _bufferOutLength));
                }
                catch
                {
                    // TODO: [vermorel] We must log exceptions here.
                    // TODO: [vermorel] In debug mode, I would still suggest to crash the server.

                    // An exception is not allowed to kill the accept loop
                }
            }
        }
Exemple #4
0
 public static void QueueSave(string Path, object Data)
 {
     SaveQueue.Append(new FileData(Path, Data));
 }