comparison Implab/Diagnostics/ActivityScope.cs @ 253:34df34841225 v3 v3.0.1-beta

Implab.Diagnostics drafts
author cin
date Mon, 12 Feb 2018 17:03:37 +0300
parents
children
comparison
equal deleted inserted replaced
252:6f4630d0bcd9 253:34df34841225
1 using System;
2 using System.Diagnostics;
3
4 namespace Implab.Diagnostics {
5 public class ActivityScope : IDisposable {
6 readonly TraceSource m_source;
7
8 readonly Guid m_prevId;
9
10 readonly string m_activity;
11
12 readonly int m_code;
13
14 internal ActivityScope(TraceSource source, Guid prevId, int code, string activity) {
15 m_source = source;
16 m_prevId = prevId;
17 m_code = code;
18 m_activity = activity;
19 }
20
21
22 public void Dispose() {
23 if (Trace.CorrelationManager.ActivityId != m_prevId)
24 m_source.TraceTransfer(m_code, "Transfer", m_prevId);
25 m_source.TraceEvent(TraceEventType.Stop, 0, m_activity);
26 Trace.CorrelationManager.ActivityId = m_prevId;
27 }
28 }
29 }