Ejemplo n.º 1
0
        private void Kernel_ThreadCSwitch(Microsoft.Diagnostics.Tracing.Parsers.Kernel.CSwitchTraceData obj)
        {
            if (SwitchContextEvent != null)
            {
                SwitchContextData sc = new SwitchContextData()
                {
                    CPUID       = (byte)obj.ProcessorNumber,
                    NewThreadID = (ulong)obj.NewThreadID,
                    OldThreadID = (ulong)obj.OldThreadID,
                    Timestamp   = obj.TimeStamp,
                };

                SwitchContextEvent.Invoke(sc);
            }

            //ProcessData newProcess = null;
            //if (ProcessDataMap.TryGetValue(obj.NewProcessID, out newProcess))
            //{
            //    ThreadData thread = newProcess.Threads[obj.NewThreadID];
            //    thread.WorkIntervals.Add(new WorkIntervalData()
            //    {
            //        Start = obj.TimeStamp,
            //        CpuID = obj.ProcessorNumber,
            //        Finish = DateTime.MinValue,
            //    });

            //    ActiveCoresMap[obj.ProcessorNumber] = thread;
            //}
            //else
            //{
            //    ActiveCoresMap[obj.ProcessorNumber] = null;
            //}

            //ProcessData oldProcess = null;
            //if (ProcessDataMap.TryGetValue(obj.OldProcessID, out oldProcess))
            //{
            //    ThreadData thread = oldProcess.Threads[obj.OldThreadID];
            //    if (thread.WorkIntervals.Count > 0)
            //    {
            //        WorkIntervalData interval = thread.WorkIntervals[thread.WorkIntervals.Count - 1];
            //        interval.Finish = obj.TimeStamp;
            //        interval.WaitReason = (int)obj.OldThreadWaitReason;
            //    }
            //}
        }
Ejemplo n.º 2
0
 public void Add(SwitchContextData sc)
 {
     Events.Add(sc);
 }
Ejemplo n.º 3
0
 private void ETWCollector_SwitchContextEvent(SwitchContextData sc)
 {
     SwitchContexts.Add(sc);
 }