当前位置: 首页>>代码示例>>C#>>正文


C# EventQueue.Enqueue方法代码示例

本文整理汇总了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;
 }
开发者ID:fastquant,项目名称:fastquant.dll,代码行数:11,代码来源:EventBus.cs

示例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" );
 }
开发者ID:taoxiease,项目名称:asegrp,代码行数:11,代码来源:EventQueueTests.cs

示例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));
     }
 }
开发者ID:fastquant,项目名称:fastquant.dll,代码行数:14,代码来源:DataSimulator.cs

示例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);
 }
开发者ID:fastquant,项目名称:fastquant.dll,代码行数:11,代码来源:DataSimulator.cs

示例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();
        }
开发者ID:fastquant,项目名称:fastquant.dll,代码行数:56,代码来源:DataSimulator.cs

示例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);
 }
开发者ID:t-h-e,项目名称:HeuristicLab,代码行数:9,代码来源:Environment.cs

示例7: EnqueueEvents

 private static void EnqueueEvents(EventQueue q)
 {
     foreach (Event e in events)
         q.Enqueue(e);
 }
开发者ID:Vernathic,项目名称:ic-AutoTest.NET4CTDD,代码行数:5,代码来源:EventQueueTests.cs

示例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);
            }
        }
开发者ID:Vernathic,项目名称:ic-AutoTest.NET4CTDD,代码行数:31,代码来源:EventQueueTests.cs

示例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));
        }
开发者ID:Vernathic,项目名称:ic-AutoTest.NET4CTDD,代码行数:29,代码来源:EventQueueTests.cs

示例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));
     }
 }
开发者ID:Vernathic,项目名称:ic-AutoTest.NET4CTDD,代码行数:14,代码来源:EventQueueTests.cs


注:本文中的EventQueue.Enqueue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。