当前位置: 首页>>代码示例>>C#>>正文


C# TraceSource.Start方法代码示例

本文整理汇总了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);
        }
开发者ID:vip32,项目名称:eventfeedback,代码行数:32,代码来源:TraceTransferScope.cs

示例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);
        }
开发者ID:vip32,项目名称:eventfeedback,代码行数:26,代码来源:TraceLogicalScope.cs


注:本文中的System.Diagnostics.TraceSource.Start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。