Ejemplo n.º 1
0
 private static void Process()
 {
     while (true)
     {
         if (shutdown)
         {
             return;
         }
         PerformanceQueueItem item = null;
         lock (sync)
         {
             if (queue.Count > 0)
             {
                 item = queue.Dequeue();
             }
         }
         if (item != null)
         {
             DispatchItem(item);
         }
         else
         {
             waitHandle.WaitOne();
         }
     }
 }
Ejemplo n.º 2
0
        public static void StopSubActivity(string subActivityName)
        {
            PerformanceQueueItem item = new PerformanceQueueItem
            {
                Time       = DateTime.Now,
                ThreadId   = Thread.CurrentThread.ManagedThreadId,
                Name       = subActivityName,
                ParentName = String.Empty,
                Action     = QueueActionType.StopSubActivity
            };

            lock (sync)
            {
                queue.Enqueue(item);
                waitHandle.Set();
            }
        }
Ejemplo n.º 3
0
        private static void DispatchItem(PerformanceQueueItem item)
        {
            switch (item.Action)
            {
            case QueueActionType.StartActivity:
                StartActivityPrivate(item.ThreadId, item.Name, item.Time);
                break;

            case QueueActionType.StopActivity:
                StopActivityPrivate(item.ThreadId, item.Name, item.Time);
                break;

            case QueueActionType.StartSubActivity:
                StartSubActivityPrivate(item.Name, item.ParentName, item.ThreadId, item.Time);
                break;

            case QueueActionType.StopSubActivity:
                StopSubActivityPrivate(item.Name, item.ThreadId, item.Time);
                break;

            default:
                throw new NotSupportedException("Queue action is not supported.");
            }
        }