本文整理汇总了C#中EventQueue.Enqueue方法的典型用法代码示例。如果您正苦于以下问题:C# EventQueue.Enqueue方法的具体用法?C# EventQueue.Enqueue怎么用?C# EventQueue.Enqueue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventQueue
的用法示例。
在下文中一共展示了EventQueue.Enqueue方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Attach
public void Attach(EventBus bus)
{
var q = new EventQueue(EventQueueId.Data, EventQueueType.Master, EventQueuePriority.Normal, 25600, null)
{
IsSynched = true,
Name = $"attached {bus.framework.Name}"
};
q.Enqueue(new OnQueueOpened(q));
bus.DataPipe.Add(q);
this.attached[this.attachedCount++] = q;
}
示例2: PumpAutoStopsOnRunFinished
public void PumpAutoStopsOnRunFinished()
{
EventQueue q = new EventQueue();
EventPump pump = new EventPump( NullListener.NULL, q, true );
Assert.IsFalse( pump.Pumping, "Should not be pumping initially" );
StartPump( pump, 1000 );
Assert.IsTrue( pump.Pumping, "Pump failed to start" );
q.Enqueue( new RunFinishedEvent( new Exception() ) );
WaitForPumpToStop( pump, 1000 );
Assert.IsFalse( pump.Pumping, "Pump failed to stop" );
}
示例3: OnConnected
protected override void OnConnected()
{
foreach (var s in Series)
{
var q = new EventQueue(EventQueueId.Data, EventQueueType.Master, EventQueuePriority.Normal, 25600, null)
{
IsSynched = true,
Name = s.Name
};
q.Enqueue(new OnQueueOpened(q));
this.framework.EventBus.DataPipe.Add(q);
this.emitters.Add(new DataSeriesObject(s, DateTime1, DateTime2, q, Processor));
}
}
示例4: CreateDataSeriesEmitter
private DataSeriesObject CreateDataSeriesEmitter(DataSeries series, DateTime dateTime1, DateTime dateTime2)
{
var q = new EventQueue(EventQueueId.Data, EventQueueType.Master, EventQueuePriority.Normal, 25600, null)
{
IsSynched = true,
Name = series.Name
};
q.Enqueue(new OnQueueOpened(q));
this.framework.EventBus.DataPipe.Add(q);
return new DataSeriesObject(series, dateTime1, dateTime2, q, Processor);
}
示例5: Run
public void Run()
{
this.thread = new Thread(() =>
{
Console.WriteLine($"{DateTime.Now} Data simulator thread started");
if (!IsConnected)
Connect();
var q = new EventQueue(EventQueueId.Data, EventQueueType.Master, EventQueuePriority.Normal, 16, null)
{
Name = "Data Simulator Start Queue",
IsSynched = true
};
q.Enqueue(new OnQueueOpened(q));
q.Enqueue(new OnSimulatorStart(DateTime1, DateTime2, 0));
q.Enqueue(new OnQueueClosed(q));
this.framework.EventBus.DataPipe.Add(q);
this.running = true;
this.exit = false;
while (!this.exit)
{
LinkedListNode<DataSeriesObject> lastNode = null;
var node = this.emitters.First;
while (node != null)
{
var emitter = node.Data;
if (!emitter.Done)
{
if (emitter.Enqueue())
this.objCount++;
lastNode = node;
}
else
{
if (lastNode == null)
this.emitters.First = node.Next;
else
lastNode.Next = node.Next;
this.emitters.Count--;
emitter.dataQueue.Enqueue(new OnQueueClosed(emitter.dataQueue));
}
node = node.Next;
}
}
this.exit = false;
this.running = false;
Console.WriteLine($"{DateTime.Now} Data simulator thread stopped");
})
{
Name = "Data Simulator Thread",
IsBackground = true
};
this.thread.Start();
}
示例6: DoSchedule
protected virtual EventQueueNode DoSchedule(DateTime date, Event @event) {
if (ScheduleQ.MaxSize == ScheduleQ.Count) {
// the capacity has to be adjusted, there are more events in the queue than anticipated
var oldSchedule = ScheduleQ;
ScheduleQ = new EventQueue(ScheduleQ.MaxSize * 2);
foreach (var e in oldSchedule) ScheduleQ.Enqueue(e.Priority, e.Event);
}
return ScheduleQ.Enqueue(date, @event);
}
示例7: EnqueueEvents
private static void EnqueueEvents(EventQueue q)
{
foreach (Event e in events)
q.Enqueue(e);
}
示例8: PumpSynchronousAndAsynchronousEvents
public void PumpSynchronousAndAsynchronousEvents()
{
EventQueue q = new EventQueue();
using (EventPump pump = new EventPump(NullListener.NULL, q, false))
{
pump.Name = "PumpSynchronousAndAsynchronousEvents";
pump.Start();
int numberOfAsynchronousEvents = 0;
int sumOfAsynchronousQueueLength = 0;
const int Repetitions = 2;
for (int i = 0; i < Repetitions; i++)
{
foreach (Event e in events)
{
q.Enqueue(e);
if (e.IsSynchronous)
{
Assert.That(q.Count, Is.EqualTo(0));
}
else
{
sumOfAsynchronousQueueLength += q.Count;
numberOfAsynchronousEvents++;
}
}
}
Console.WriteLine("Average queue length: {0}", (float)sumOfAsynchronousQueueLength / numberOfAsynchronousEvents);
}
}
示例9: PumpPendingEventsAfterAutoStop
public void PumpPendingEventsAfterAutoStop()
{
EventQueue q = new EventQueue();
EnqueueEvents(q);
Event[] eventsAfterStop =
{
new OutputEvent(new TestOutput("foo", TestOutputType.Out)),
new OutputEvent(new TestOutput("bar", TestOutputType.Trace)),
};
foreach (Event e in eventsAfterStop)
{
q.Enqueue(e);
}
QueuingEventListener el = new QueuingEventListener();
using (EventPump pump = new EventPump(el, q, true))
{
pump.Name = "PumpPendingEventsAfterAutoStop";
pump.Start();
int tries = 10;
while (--tries > 0 && q.Count > 0)
{
Thread.Sleep(100);
}
Assert.That(pump.PumpState, Is.EqualTo(EventPumpState.Stopped));
}
Assert.That(el.Events.Count, Is.EqualTo(events.Length + eventsAfterStop.Length));
}
示例10: PumpAutoStopsOnRunFinished
public void PumpAutoStopsOnRunFinished()
{
EventQueue q = new EventQueue();
using (EventPump pump = new EventPump(NullListener.NULL, q, true))
{
pump.Name = "PumpAutoStopsOnRunFinished";
Assert.That(pump.PumpState, Is.EqualTo(EventPumpState.Stopped));
StartPump(pump, 1000);
Assert.That(pump.PumpState, Is.EqualTo(EventPumpState.Pumping));
q.Enqueue(new RunFinishedEvent(new Exception()));
WaitForPumpToStop(pump, 1000);
Assert.That(pump.PumpState, Is.EqualTo(EventPumpState.Stopped));
}
}