コード例 #1
0
 public WebLogManager(Client client)
 {
     if (client == null)
     {
         throw new ArgumentNullException("client");
     }
     ReloadControls = new List <IComponentControl>();
     Client         = client;
     LogQueue       = new WebLogQueue();
     TaskQueue      = new ThreadTaskQueue(client.Config.Logs.WebLog.Threads);
 }
コード例 #2
0
 public EventManager(Client client)
 {
     if (client == null)
     {
         throw new ArgumentNullException("client");
     }
     Client            = client;
     Queue             = new EventQueue(client);
     TaskQueue         = new ThreadTaskQueue(client.Config.Events.EventManager.Threads);
     PrepareDataHelper = new PrepareDataHelper(client);
 }
コード例 #3
0
        public void ProcessSimpleEventThreadSafe2()
        {
            var       account     = TestHelper.GetTestAccount();
            var       component   = account.CreateRandomComponentControl();
            const int threadCount = 5;
            var       queue       = new ThreadTaskQueue(threadCount);
            var       responses   = new List <SendEventResponse>();
            var       action      = new ThreadStart(() =>
            {
                var response = component
                               .CreateApplicationError("test")
                               .SetJoinInterval(TimeSpan.FromHours(1))
                               .Send();

                lock (responses)
                {
                    responses.Add(response);
                }
            });

            for (int i = 0; i < threadCount; i++)
            {
                queue.Add(action);
            }
            queue.WaitForAllTasksCompleted();

            // все запросы выполнены успешно
            var successCount = responses.Count(x => x.Success);

            Assert.Equal(threadCount, successCount);

            // получилось 1 событие
            var eventIds = responses.Select(x => x.Data.EventId).Distinct().ToList();

            Assert.Equal(1, eventIds.Count);
        }