本文整理汇总了C#中TraceSource.TraceTransfer方法的典型用法代码示例。如果您正苦于以下问题:C# TraceSource.TraceTransfer方法的具体用法?C# TraceSource.TraceTransfer怎么用?C# TraceSource.TraceTransfer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TraceSource
的用法示例。
在下文中一共展示了TraceSource.TraceTransfer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldLogWithXmlRollingListenerNoConfig
public void ShouldLogWithXmlRollingListenerNoConfig()
{
// Setup source and listener
string initializationString =
@"name = XmlLogger; logrootpath = c:\logs; staticpattern = log_; maxSizeBytes = 20000;";
XmlWriterRollingTraceListener traceListener =
new XmlWriterRollingTraceListener(initializationString);
TraceSource log = new TraceSource("Test", SourceLevels.All);
log.Listeners.Clear();
log.Listeners.Add(traceListener);
// Start Activity #1
Guid activity1Guid = Guid.NewGuid();
Trace.CorrelationManager.ActivityId = activity1Guid;
log.TraceEvent(TraceEventType.Start, 2, "Activity #1");
// log information inside Activity #1
log.TraceInformation("Information from Activity #1");
// Start Activity #2
Guid activity2Guid = Guid.NewGuid();
log.TraceTransfer(3, "Transferring to Activity #2", activity2Guid);
Trace.CorrelationManager.ActivityId = activity2Guid;
log.TraceData(TraceEventType.Start, 4, "Activity #2");
// Complete Activity #2
log.TraceEvent(TraceEventType.Stop, 5, "Completing Activity #2");
log.TraceTransfer(6, "Returning back to Activity #1", activity1Guid);
// Get back into Activity #1
Trace.CorrelationManager.ActivityId = activity1Guid;
// Log something extra in Activity #1 before completing it
log.TraceEvent(TraceEventType.Warning, 7, "Warning from Activity #1");
// Complete Activity #1
log.TraceEvent(TraceEventType.Stop, 8, "Completing Activity #1");
}
示例2: TraceTransferTest
public void TraceTransferTest()
{
var trace = new TraceSource("TestTraceSource", SourceLevels.All);
var listener = GetTraceListener();
trace.Listeners.Add(listener);
trace.TraceTransfer(1, "Trace transfer test message", Trace.CorrelationManager.ActivityId);
Assert.Equal(1, listener.GetCallCount(Method.TraceTransfer));
var flushExpected = AutoFlush ? 1 : 0;
Assert.Equal(flushExpected, listener.GetCallCount(Method.Flush));
}