本文整理汇总了C#中System.Diagnostics.Tracing.EventSource.ReportOutOfBandMessage方法的典型用法代码示例。如果您正苦于以下问题:C# EventSource.ReportOutOfBandMessage方法的具体用法?C# EventSource.ReportOutOfBandMessage怎么用?C# EventSource.ReportOutOfBandMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Diagnostics.Tracing.EventSource
的用法示例。
在下文中一共展示了EventSource.ReportOutOfBandMessage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateFilter
/// <summary>
/// Currently this has "override" semantics. We first disable all filters
/// associated with 'source', and next we add new filters for each entry in the
/// string 'startEvents'. participateInSampling specifies whether non-startEvents
/// always trigger or only trigger when current activity is 'active'.
/// </summary>
public static void UpdateFilter(
ref ActivityFilter filterList,
EventSource source,
int perEventSourceSessionId,
string startEvents)
{
Contract.Assert(Monitor.IsEntered(EventListener.EventListenersLock));
// first remove all filters associated with 'source'
DisableFilter(ref filterList, source);
if (!string.IsNullOrEmpty(startEvents))
{
// ActivitySamplingStartEvents is a space-separated list of Event:Frequency pairs.
// The Event may be specified by name or by ID. Errors in parsing such a pair
// result in the error being reported to the listeners, and the pair being ignored.
// E.g. "CustomActivityStart:1000 12:10" specifies that for event CustomActivityStart
// we should initiate activity tracing once every 1000 events, *and* for event ID 12
// we should initiate activity tracing once every 10 events.
string[] activityFilterStrings = startEvents.Split(' ');
for (int i = 0; i < activityFilterStrings.Length; ++i)
{
string activityFilterString = activityFilterStrings[i];
int sampleFreq = 1;
int eventId = -1;
int colonIdx = activityFilterString.IndexOf(':');
if (colonIdx < 0)
{
source.ReportOutOfBandMessage("ERROR: Invalid ActivitySamplingStartEvent specification: " +
activityFilterString, false);
// ignore failure...
continue;
}
string sFreq = activityFilterString.Substring(colonIdx + 1);
if (!int.TryParse(sFreq, out sampleFreq))
{
source.ReportOutOfBandMessage("ERROR: Invalid sampling frequency specification: " + sFreq, false);
continue;
}
activityFilterString = activityFilterString.Substring(0, colonIdx);
if (!int.TryParse(activityFilterString, out eventId))
{
// reset eventId
eventId = -1;
// see if it's an event name
for (int j = 0; j < source.m_eventData.Length; j++)
{
EventSource.EventMetadata[] ed = source.m_eventData;
if (ed[j].Name != null && ed[j].Name.Length == activityFilterString.Length &&
string.Compare(ed[j].Name, activityFilterString, StringComparison.OrdinalIgnoreCase) == 0)
{
eventId = ed[j].Descriptor.EventId;
break;
}
}
}
if (eventId < 0 || eventId >= source.m_eventData.Length)
{
source.ReportOutOfBandMessage("ERROR: Invalid eventId specification: " + activityFilterString, false);
continue;
}
EnableFilter(ref filterList, source, perEventSourceSessionId, eventId, sampleFreq);
}
}
}