예제 #1
0
        public bool SendAll(LoggingConnection loggingConnection)
        {
            while (!pendingQueue.IsEmpty || sendingBuffer.Count > 0)
            {
                if (!SendSome(loggingConnection))
                {
                    return(false);
                }
            }

            return(true);
        }
예제 #2
0
        bool SendSome(LoggingConnection loggingConnection)
        {
            const int    max = 200; //200 seems like a good max. 50 gets 2250 milliconds, 100 gets 1700, 200 get 1450 for sending total 5000 trace messages
            int          i   = 0;
            TraceMessage tm;

            while ((sendingBuffer.Count < max) && pendingQueue.TryDequeue(out tm))
            {
                sendingBuffer.Add(tm);
                i++;
            }

            if (sendingBuffer.Count > 0)
            {
                try
                {
                    var task = loggingConnection.Invoke("UploadTraces", sendingBuffer);
                    if (task != null)
                    {
                        task.Wait(10000);
                    }
                    else
                    {
                        return(false);
                    }
                    sendingBuffer.Clear();
                }
                catch (AggregateException ex)
                {
                    Console.WriteLine(ex.ToString());
                    return(false);
                }
            }

            return(true);
        }