public void CreatingDuplicateRealtimeSessionTaskResultsInFaultedTaskIfSessionReclaimIsOff() { const string duplicateSessionName = "testDuplicateRealtimeSession"; using (var reader1 = new ETWRealtimeProcessor(duplicateSessionName, true)) { reader1.SubscribeToProvider(TestLogger.Write.Guid, EventLevel.Verbose); var t1 = reader1.CreateProcessingTask(); Assert.AreEqual(TaskStatus.Running, t1.Status); using (var reader2 = new ETWRealtimeProcessor(duplicateSessionName, false)) { reader2.SubscribeToProvider(TestLogger.Write.Guid, EventLevel.Verbose); try { var t2 = reader2.CreateProcessingTask(); t2.Wait(); // expect this to fail } catch (AggregateException ex) { Assert.AreEqual(typeof(OperationCanceledException), ex.InnerException.GetType()); } } Assert.AreEqual(TaskStatus.Running, t1.Status); reader1.StopProcessing(); t1.Wait(); } }
public void CanReadEventsFromRealtimeSession() { this.sessionName = "testRealtimeSession"; CheckElevated(); using (var reader = new ETWRealtimeProcessor(this.sessionName)) { reader.SubscribeToProvider(TestLogger.Write.Guid, EventLevel.Verbose); reader.EventProcessed += delegate(ETWEvent entry) { this.ValidateEventArgs(entry); if (this.eventsRead == 4) { reader.StopProcessing(); } }; var processorTask = reader.CreateProcessingTask(); WriteTestEvents(); processorTask.Wait(); Assert.IsTrue(processorTask.IsCompleted); Assert.AreEqual(4, this.eventsRead); Assert.AreEqual(0, reader.UnreadableEvents); } }