本文整理汇总了C#中EventQueue类的典型用法代码示例。如果您正苦于以下问题:C# EventQueue类的具体用法?C# EventQueue怎么用?C# EventQueue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EventQueue类属于命名空间,在下文中一共展示了EventQueue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EventPumpQueueLength
public void EventPumpQueueLength(int numberOfProducers, bool producerDelay)
{
EventQueue q = new EventQueue();
EventProducer[] producers = new EventProducer[numberOfProducers];
for (int i = 0; i < numberOfProducers; i++)
{
producers[i] = new EventProducer(q, i, producerDelay);
}
using (EventPump pump = new EventPump(NullListener.NULL, q, false))
{
pump.Name = "EventPumpQueueLength";
pump.Start();
foreach (EventProducer p in producers)
{
p.ProducerThread.Start();
}
foreach (EventProducer p in producers)
{
p.ProducerThread.Join();
}
pump.Stop();
}
Assert.That(q.Count, Is.EqualTo(0));
foreach (EventProducer p in producers)
{
Console.WriteLine(
"#Events: {0}, MaxQueueLength: {1}", p.SentEventsCount, p.MaxQueueLength);
Assert.IsNull(p.Exception, "{0}", p.Exception);
}
}
示例2: EventList
public EventList(EventQueue<string> events)
{
InitializeComponent();
EventQueue = events;
EventQueue.Updated += Events_Updated;
ReloadEvents();
}
示例3: EventManager
/**
* EventManager constructor comment.
*
* @param robotProxy robotProxy
*/
public EventManager(BasicRobotProxy robotProxy)
{
registerNamedEvents();
this.robotProxy = robotProxy;
eventQueue = new EventQueue();
reset();
}
示例4: EventManager
/// <summary>
/// Constructs a new EventManager.
/// </summary>
/// <param name="robotProxy">the robot proxy that this event manager applies to.</param>
public EventManager(BasicRobotProxy robotProxy)
{
this.robotProxy = robotProxy;
eventQueue = new EventQueue();
RegisterEventNames();
Reset();
}
示例5: Environment
public Environment(DateTime initialDateTime, int randomSeed, TimeSpan? defaultStep = null) {
DefaultTimeStepSeconds = (defaultStep ?? TimeSpan.FromSeconds(1)).Duration().TotalSeconds;
StartDate = initialDateTime;
Now = initialDateTime;
Random = new SystemRandom(randomSeed);
ScheduleQ = new EventQueue(InitialMaxEvents);
Queue = new Queue<Event>();
Logger = Console.Out;
}
示例6: Server
/// <summary>
/// start a small server that listens to UDP messages through _port 1337(as indicated when initializing the server instance).
/// </summary>
/// <param name="_port"></param>
public Server(int _port)
{
this._iPort = _port;
_lMessageBacklog = new EventQueue<NetworkMessage>();
_lPlayerRooms = new EventList<Hub>();
Instance = this;
Console.WriteLine("Setting up the server...");
MessageReceived += ParseMessage;
}
示例7: EventOptions
/// <summary>
/// Default constructor
/// </summary>
public EventOptions()
{
HostName = _hostName;
OnErrorHttpCaptureFlags = HttpCaptureFlags.All;
SourceLevels = SourceLevels.All;
ConfigKeys = new Keys();
ConnectorType = "HashTag.Logging.Client.NLog.NLogEventConnector, HashTag.Logging.Client";
_queue = new EventQueue(this);
}
示例8: VerifyQueue
private static void VerifyQueue(EventQueue q)
{
for (int index = 0; index < events.Length; index++)
{
Event e = q.Dequeue(false);
Assert.AreEqual(events[index].GetType(), e.GetType(),
string.Format("Event {0}", index));
}
}
示例9: 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" );
}
示例10: SetUp
public void SetUp()
{
theQueue = new EventQueue<FakeTopic>();
theQueue.Write(new ServerEvent("2", "2"));
theQueue.Write(new ServerEvent("1", "1"));
for (int i = 3; i < 8; i++)
{
theQueue.Write(new ServerEvent(i.ToString(), i.ToString()));
}
}
示例11: 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;
}
示例12: PumpEvents
public void PumpEvents()
{
EventQueue q = new EventQueue();
EnqueueEvents( q );
QueuingEventListener el = new QueuingEventListener();
EventPump pump = new EventPump( el, q, false );
Assert.IsFalse( pump.Pumping, "Should not be pumping initially" );
StartPump( pump, 1000 );
Assert.IsTrue( pump.Pumping, "Pump should still be running" );
StopPump( pump, 1000 );
Assert.IsFalse( pump.Pumping, "Pump should have stopped" );
VerifyQueue( el.Events );
}
示例13: 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));
}
}
示例14: PumpEventsWithAutoStop
public void PumpEventsWithAutoStop()
{
EventQueue q = new EventQueue();
EnqueueEvents( q );
QueuingEventListener el = new QueuingEventListener();
EventPump pump = new EventPump( el, q, true );
pump.Start();
int tries = 10;
while( --tries > 0 && q.Count > 0 )
{
Thread.Sleep(100);
}
VerifyQueue( el.Events );
Assert.IsFalse( pump.Pumping, "Pump failed to stop" );
}
示例15: spin_up_pre_builds
public void spin_up_pre_builds()
{
var factory = MockRepository.GenerateMock<IEventQueueFactory<FakeTopic>>();
var queue = new EventQueue<FakeTopic>();
var topic = new FakeTopic{
Name = "Top"
};
factory.Stub(x => x.BuildFor(topic)).Return(queue);
var family = new TopicFamily<FakeTopic>(factory);
family.SpinUpChannel(topic);
factory.AssertWasCalled(x => x.BuildFor(topic));
}