annotate Implab/Diagnostics/ActivityScope.cs @ 255:b00441e04738 v3

Adde workaround to the behaviour of the logical operations stack in conjuction with async/await methods
author cin
date Wed, 04 Apr 2018 15:38:48 +0300
parents 34df34841225
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
253
34df34841225 Implab.Diagnostics drafts
cin
parents:
diff changeset
1 using System;
34df34841225 Implab.Diagnostics drafts
cin
parents:
diff changeset
2 using System.Diagnostics;
34df34841225 Implab.Diagnostics drafts
cin
parents:
diff changeset
3
34df34841225 Implab.Diagnostics drafts
cin
parents:
diff changeset
4 namespace Implab.Diagnostics {
34df34841225 Implab.Diagnostics drafts
cin
parents:
diff changeset
5 public class ActivityScope : IDisposable {
34df34841225 Implab.Diagnostics drafts
cin
parents:
diff changeset
6 readonly TraceSource m_source;
34df34841225 Implab.Diagnostics drafts
cin
parents:
diff changeset
7
34df34841225 Implab.Diagnostics drafts
cin
parents:
diff changeset
8 readonly Guid m_prevId;
34df34841225 Implab.Diagnostics drafts
cin
parents:
diff changeset
9
34df34841225 Implab.Diagnostics drafts
cin
parents:
diff changeset
10 readonly string m_activity;
34df34841225 Implab.Diagnostics drafts
cin
parents:
diff changeset
11
34df34841225 Implab.Diagnostics drafts
cin
parents:
diff changeset
12 readonly int m_code;
34df34841225 Implab.Diagnostics drafts
cin
parents:
diff changeset
13
34df34841225 Implab.Diagnostics drafts
cin
parents:
diff changeset
14 internal ActivityScope(TraceSource source, Guid prevId, int code, string activity) {
34df34841225 Implab.Diagnostics drafts
cin
parents:
diff changeset
15 m_source = source;
34df34841225 Implab.Diagnostics drafts
cin
parents:
diff changeset
16 m_prevId = prevId;
34df34841225 Implab.Diagnostics drafts
cin
parents:
diff changeset
17 m_code = code;
34df34841225 Implab.Diagnostics drafts
cin
parents:
diff changeset
18 m_activity = activity;
34df34841225 Implab.Diagnostics drafts
cin
parents:
diff changeset
19 }
34df34841225 Implab.Diagnostics drafts
cin
parents:
diff changeset
20
34df34841225 Implab.Diagnostics drafts
cin
parents:
diff changeset
21
34df34841225 Implab.Diagnostics drafts
cin
parents:
diff changeset
22 public void Dispose() {
34df34841225 Implab.Diagnostics drafts
cin
parents:
diff changeset
23 if (Trace.CorrelationManager.ActivityId != m_prevId)
34df34841225 Implab.Diagnostics drafts
cin
parents:
diff changeset
24 m_source.TraceTransfer(m_code, "Transfer", m_prevId);
34df34841225 Implab.Diagnostics drafts
cin
parents:
diff changeset
25 m_source.TraceEvent(TraceEventType.Stop, 0, m_activity);
34df34841225 Implab.Diagnostics drafts
cin
parents:
diff changeset
26 Trace.CorrelationManager.ActivityId = m_prevId;
34df34841225 Implab.Diagnostics drafts
cin
parents:
diff changeset
27 }
34df34841225 Implab.Diagnostics drafts
cin
parents:
diff changeset
28 }
34df34841225 Implab.Diagnostics drafts
cin
parents:
diff changeset
29 }