本文整理汇总了C#中System.Diagnostics.Tracing.EventSource.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# EventSource.Dispose方法的具体用法?C# EventSource.Dispose怎么用?C# EventSource.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Diagnostics.Tracing.EventSource
的用法示例。
在下文中一共展示了EventSource.Dispose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_BadTypes_Manifest
private void Test_BadTypes_Manifest(EventSource source)
{
try
{
var listener = new EventListenerListener();
var events = new List<Event>();
Debug.WriteLine("Adding delegate to onevent");
listener.OnEvent = delegate (Event data) { events.Add(data); };
listener.EventSourceCommand(source.Name, EventCommand.Enable);
listener.Dispose();
// Confirm that we get exactly one event from this whole process, that has the error message we expect.
Assert.Equal(events.Count, 1);
Event _event = events[0];
Assert.Equal("EventSourceMessage", _event.EventName);
string message = _event.PayloadString(0, "message");
// expected message: "ERROR: Exception in Command Processing for EventSource BadEventSource_Bad_Type_ByteArray: Unsupported type Byte[] in event source. "
Assert.True(Regex.IsMatch(message, "Unsupported type"));
}
finally
{
source.Dispose();
}
}
示例2: Test_EventSourceCreatedEvents_AfterListener
public void Test_EventSourceCreatedEvents_AfterListener()
{
TestUtilities.CheckNoEventSourcesRunning("Start");
EventSource log = null;
EventSource log2 = null;
EventListenerListener el = null;
try
{
el = new EventListenerListener();
string esName = "EventSourceName_HopefullyUnique";
string esName2 = "EventSourceName_HopefullyUnique2";
bool esNameHit = false;
bool esName2Hit = false;
List<EventSource> eventSourceNotificationsReceived = new List<EventSource>();
el.EventSourceCreated += (s, a) =>
{
if(a.EventSource.Name.Equals(esName))
{
esNameHit = true;
}
if (a.EventSource.Name.Equals(esName2))
{
esName2Hit = true;
}
};
log = new EventSource(esName);
log2 = new EventSource(esName2);
Thread.Sleep(1000);
Assert.Equal(true, esNameHit);
Assert.Equal(true, esName2Hit);
}
finally
{
if (log != null)
{
log.Dispose();
}
if (log2 != null)
{
log2.Dispose();
}
if (el != null)
{
el.Dispose();
}
}
TestUtilities.CheckNoEventSourcesRunning("Stop");
}