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


C# TraceSource.TraceTransfer方法代码示例

本文整理汇总了C#中System.Diagnostics.TraceSource.TraceTransfer方法的典型用法代码示例。如果您正苦于以下问题:C# TraceSource.TraceTransfer方法的具体用法?C# TraceSource.TraceTransfer怎么用?C# TraceSource.TraceTransfer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Diagnostics.TraceSource的用法示例。


在下文中一共展示了TraceSource.TraceTransfer方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Main

        static void Main(string[] args)
        {
            // Create activity to contain the other activities
            var ts = new TraceSource("MyServiceTraceSource");
            Guid mainActivityId = Guid.NewGuid();
            Trace.CorrelationManager.ActivityId = mainActivityId;
            ts.TraceEvent(TraceEventType.Start, 0, "Main Activity");

            // Create new activity and transfer to it
            Guid newActivityId = Guid.NewGuid();
            ts.TraceTransfer(0, "Transferring...", newActivityId);
            Trace.CorrelationManager.ActivityId = newActivityId;
            ts.TraceEvent(TraceEventType.Start, 0, "GetHeader Activity");

            // Call operation
            using (MyServiceClient proxy = new MyServiceClient("WSHttpBinding_MyService"))
            {
                try
                {
                    Console.WriteLine(proxy.GetHeader("MyHeader", "http://tempuri.org"));
                    ts.TraceEvent(TraceEventType.Information, 0, "GetHeader succeeded!");
                }
                catch (FaultException<string> ex)
                {
                    Console.WriteLine(ex.Reason);
                    Console.WriteLine(ex.Detail);
                    ts.TraceEvent(TraceEventType.Error, 0,
                        "GetHeader failed.\nReason:{0}\nDetail{1}",
                        ex.Reason, ex.Detail);
                }
            }

            // Transfer back to main activity
            ts.TraceTransfer(666, "Transferring...", mainActivityId);
            ts.TraceEvent(TraceEventType.Stop, 0, "GetHeader Activity");
            Trace.CorrelationManager.ActivityId = mainActivityId;

            // Stop the main activity
            ts.TraceEvent(TraceEventType.Stop, 0, "Main Activity");

            Console.ReadKey();
        }
开发者ID:sajjadahmadi,项目名称:wcf-examples,代码行数:42,代码来源:Program.cs

示例3: TraceCorrelationScope

		public TraceCorrelationScope(Guid activity, TraceSource source, bool traceTransfer)
		{
			this.old = Trace.CorrelationManager.ActivityId;

			_Transfered = old != activity && traceTransfer;
			if(_Transfered)
			{
				_Source = source;
				_Source.TraceTransfer(0, "t", activity);
			}
			Trace.CorrelationManager.ActivityId = activity;
		}
开发者ID:crowar,项目名称:NBitcoin,代码行数:12,代码来源:TraceCorrelationScope.cs

示例4: ActivityTraceContext

        public ActivityTraceContext(TraceSource ts, string operationName)
        {
            this.operationName = operationName;
            this.ts = ts;

            Trace.CorrelationManager.StartLogicalOperation(operationName);

            parentActivityId = Trace.CorrelationManager.ActivityId;
            Guid activityId = Guid.NewGuid();

            ts.TraceTransfer(0, "Transfering to " + operationName, activityId);
            Trace.CorrelationManager.ActivityId = activityId;
            ts.TraceEvent(TraceEventType.Start, 0, operationName + " started");
        }
开发者ID:arucard21,项目名称:AniDB,代码行数:14,代码来源:ActivityTraceContext.cs

示例5: ScopedActivity

        public ScopedActivity(string name, bool transfer = true)
        {
            ActivityId = Guid.NewGuid();
            TraceSource = new TraceSource("EmailingSystem.Service", SourceLevels.All);

            //if transferring from previous activity...
            if (transfer)
            {
                //capture old activity id
                PriorActivityId = Trace.CorrelationManager.ActivityId;

                //tansfer to new activity id with new trace source
                TraceSource.TraceTransfer(0, "Transferring", ActivityId);
            }

            //set activity and trace start event
            Trace.CorrelationManager.ActivityId = ActivityId;
            TraceSource.TraceEvent(TraceEventType.Start, 0, name);
        }
开发者ID:JoeBuntu,项目名称:Smtp-Server,代码行数:19,代码来源:ScopedActivity.cs

示例6: TestTrace

        public void TestTrace()
        {
            TraceSource wcfTrace = new TraceSource("System.ServiceModel");
            Guid currentActivity = Trace.CorrelationManager.ActivityId;
            Guid newActivity = Guid.NewGuid();
            Guid newActivity2 = Guid.NewGuid();

            Guid newActivity3 = Guid.NewGuid();

            wcfTrace.TraceEvent(TraceEventType.Start, 100, "[+] Method entered");

            wcfTrace.TraceEvent(TraceEventType.Information, 101, "[+] In current activity");

            wcfTrace.TraceEvent(TraceEventType.Start, 100, "[+] Still in current activity");

            wcfTrace.TraceEvent(TraceEventType.Information, 102, "[+] Still in current activity");

            wcfTrace.TraceTransfer(0, "[+] Start Level 1 activity", newActivity);

            Trace.CorrelationManager.ActivityId = newActivity;

            wcfTrace.TraceEvent(TraceEventType.Information, 103, "[+] Hello from Level 1");

            wcfTrace.TraceEvent(TraceEventType.Warning, 104, "[+] Level 1");
            wcfTrace.TraceEvent(TraceEventType.Error, 103, "[+] Level 1");
            wcfTrace.TraceEvent(TraceEventType.Critical, 105, "[+] Level 1");
            wcfTrace.TraceTransfer(0, "[+] Start Level 2 activity", newActivity2);

            Trace.CorrelationManager.ActivityId = newActivity2;

            wcfTrace.TraceEvent(TraceEventType.Information, 102, "[+] Hello from Level 2");

            wcfTrace.TraceEvent(TraceEventType.Information, 103, "[+] Level 2");

            wcfTrace.TraceTransfer(0, "[+] Jump back to level 1", newActivity);

            Trace.CorrelationManager.ActivityId = newActivity;

            wcfTrace.TraceEvent(TraceEventType.Transfer, 101, "[+] Hello from Level 1");

            wcfTrace.TraceEvent(TraceEventType.Information, 102, "[+] Level 1");

            wcfTrace.TraceTransfer(0, "[+] Jump back to current",

            currentActivity);

            Trace.CorrelationManager.ActivityId = currentActivity;

            wcfTrace.TraceEvent(TraceEventType.Information, 103, "[+] Again in current activity");

            wcfTrace.TraceEvent(TraceEventType.Stop, 101, "[+] Method exited");
        }
开发者ID:tininess,项目名称:HostTamTruTamVang,代码行数:52,代码来源:HostService.cs

示例7: Main

        static void Main()
        {
            TraceSource ts = new TraceSource("ClientCalculatorTraceSource");

            // Start the calculator activity
            Guid newGuid = Guid.NewGuid();
            Trace.CorrelationManager.ActivityId = newGuid;
            ts.TraceEvent(TraceEventType.Start, 0, "Calculator Activity");

            // Create a proxy with given client endpoint configuration
            using (CalculatorProxy proxy = new CalculatorProxy())
            {
                // Save the calculator activity id to transfer back and forth from/to it
                Guid originalGuid = Trace.CorrelationManager.ActivityId;

                // Create and start the Add activity                
                // Generate a new activity id
                newGuid = Guid.NewGuid();
                // Transfer from the calculator activity to the new (Add) activity
                // The value for the "from" in the transfer is implicit; it is the activity id 
                // previously set in Trace.CorrelationManager.ActivityId
                // The value for the "to" is explicitly passed as the newGuid parameter
                ts.TraceTransfer(0, "Transferring...", newGuid);
                // Set the new activity id in Trace.CorrelationManager.ActivityId; it is now in scope
                // for subsequently emitted traces
                Trace.CorrelationManager.ActivityId = newGuid;
                // Emit the Start trace for the new activity
                ts.TraceEvent(TraceEventType.Start, 0, "Add Activity");

                // Now make the Add request
                double value1 = 100.00D;
                double value2 = 15.99D;
                ts.TraceEvent(TraceEventType.Information, 0,
                    "Client sends Add request message.");
                double result = proxy.Add(value1, value2);

                // Trace that you have received the response
                ts.TraceEvent(TraceEventType.Information, 0,
                    "Client receives Add response message.");
                Console.WriteLine("Add({0},{1}) = {2}", value1, value2, result);

                // Transfer back to the Calculator activity and stop the current activity
                ts.TraceTransfer(667, "Transferring...", originalGuid);
                ts.TraceEvent(TraceEventType.Stop, 0, "Add Activity");

                // Set the calculator activity back in scope
                Trace.CorrelationManager.ActivityId = originalGuid;


                // Call the Subtract service operation
                newGuid = Guid.NewGuid();
                ts.TraceTransfer(0, "Transferring...", newGuid);
                Trace.CorrelationManager.ActivityId = newGuid;
                ts.TraceEvent(TraceEventType.Start, 0, "Subtract Activity");

                value1 = 100.00D;
                value2 = 15.99D;
                ts.TraceEvent(TraceEventType.Information, 0,
                    "Client sends Subtract request message.");
                result = proxy.Subtract(value1, value2);
                ts.TraceEvent(TraceEventType.Information, 0,
                    "Client receives Subtract response message.");
                Console.WriteLine("Subtract({0},{1}) = {2}", value1, value2, result);

                ts.TraceTransfer(667, "Transferring...", originalGuid);
                ts.TraceEvent(TraceEventType.Stop, 0, "Subtract Activity");
                Trace.CorrelationManager.ActivityId = originalGuid;


                // Call the Multiply service operation
                newGuid = Guid.NewGuid();
                ts.TraceTransfer(0, "Transferring...", newGuid);
                Trace.CorrelationManager.ActivityId = newGuid;
                ts.TraceEvent(TraceEventType.Start, 0, "Multiply Activity");

                value1 = 100.00D;
                value2 = 15.99D;
                ts.TraceEvent(TraceEventType.Information, 0,
                    "Client sends Multiply request message.");
                result = proxy.Multiply(value1, value2);
                ts.TraceEvent(TraceEventType.Information, 0,
                    "Client receives Multiply response message.");
                Console.WriteLine("Multiply({0},{1}) = {2}", value1, value2, result);

                ts.TraceTransfer(667, "Transferring...", originalGuid);
                ts.TraceEvent(TraceEventType.Stop, 0, "Multiply Activity");
                Trace.CorrelationManager.ActivityId = originalGuid;


                // Call the Divide service operation
                newGuid = Guid.NewGuid();
                ts.TraceTransfer(0, "Transferring...", newGuid);
                Trace.CorrelationManager.ActivityId = newGuid;
                ts.TraceEvent(TraceEventType.Start, 0, "Divide Activity");

                value1 = 100.00D;
                value2 = 15.99D;
                ts.TraceEvent(TraceEventType.Information, 0,
                    "Client sends Divide request message.");
                result = proxy.Divide(value1, value2);
//.........这里部分代码省略.........
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:101,代码来源:client.cs

示例8: ActivityScope

        public ActivityScope(TraceSource source, int transferInId, int startId, int transferOutId, int stopId)
        {
            _source = source;
            _startId = startId;
            _stopId = stopId;
            _transferInId = transferInId;
            _transferOutId = transferOutId;

            _previousActivityId = Trace.CorrelationManager.ActivityId;

            // Log Transfer In
            Guid newActivity = Guid.NewGuid();
            if (_source != null)
            {
                _source.TraceTransfer(_transferInId, ActivityScope_Transfer, newActivity);
            }
            Trace.CorrelationManager.ActivityId = newActivity;

            // Log Start Message
            if (_source != null)
            {
                _source.TraceEvent(TraceEventType.Start, _startId, ActivityScope_Start);
            }
        }
开发者ID:xsolon,项目名称:if,代码行数:24,代码来源:ActivityScope.cs

示例9: SwitchToActivity

 /// <summary>
 /// The switch to activity.
 /// </summary>
 /// <param name="activityId">
 /// The activity id.
 /// </param>
 /// <param name="activityInfo">
 /// The activity info.
 /// </param>
 /// <param name="localTrace">
 /// The local trace.
 /// </param>
 private static void SwitchToActivity(Guid activityId, string activityInfo, TraceSource localTrace)
 {
     var activityMessage = string.IsNullOrEmpty(activityInfo) ? "Starting new Activity..." : activityInfo;
     // Trace.TraceInformation("ID: {0}, Message: {1}", activityId, activityMessage);
     GlobalTrace.TraceTransfer(Counter.Value, activityMessage, activityId);
     localTrace.TraceTransfer(Counter.Value, activityMessage, activityId);
 }
开发者ID:matthid,项目名称:actorvsthreads,代码行数:19,代码来源:Logger.cs


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