本文整理汇总了C#中System.Diagnostics.TraceSource.Start方法的典型用法代码示例。如果您正苦于以下问题:C# TraceSource.Start方法的具体用法?C# TraceSource.Start怎么用?C# TraceSource.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Diagnostics.TraceSource
的用法示例。
在下文中一共展示了TraceSource.Start方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TraceTransferScope
/// <summary>
/// Constructor used to initialize the class
/// </summary>
/// <param name="traceSource">The source that we are tracing through as part of this scope</param>
/// <param name="activityName">The name of the activity that this scope represents</param>
public TraceTransferScope(TraceSource traceSource, string activityName)
{
if (traceSource == null)
{
throw new ArgumentNullException("traceSource");
}
if (string.IsNullOrEmpty(activityName))
{
throw new ArgumentNullException("activityName");
}
_traceSource = traceSource;
_oldActivityId = Trace.CorrelationManager.ActivityId;
_activityName = activityName;
_newActivityId = Guid.NewGuid();
if (_oldActivityId != Guid.Empty)
{
// transfer to activity
_traceSource.TraceTransfer(0, string.Format(CultureInfo.CurrentCulture, "TRANSFER ==> {0} ===", _activityName), _newActivityId);
}
Trace.CorrelationManager.ActivityId = _newActivityId;
_traceSource.Start(_activityName);
}
示例2: TraceLogicalScope
/// <summary>
/// Constructor used to initialize the class
/// </summary>
/// <param name="traceSource">The source that we are tracing through as part of this scope</param>
/// <param name="logicalName">The name of the logical block that this scope represents</param>
public TraceLogicalScope(TraceSource traceSource, string logicalName)
{
if (traceSource == null)
{
throw new ArgumentNullException("traceSource");
}
if (string.IsNullOrEmpty(logicalName))
{
throw new ArgumentNullException("logicalName");
}
_traceSource = traceSource;
_logicalName = logicalName;
if (Trace.CorrelationManager.ActivityId.Equals(Guid.Empty))
Trace.CorrelationManager.ActivityId = Guid.NewGuid();
// _traceSource.TraceInformation("REQUEST === {0}", _logicalName);
_traceSource.Start("BEGIN === {0} (ActivityId: {1}) ===", _logicalName, Trace.CorrelationManager.ActivityId);
}