61 lines
1.3 KiB
C#
61 lines
1.3 KiB
C#
using Api.Framework.Events;
|
|
using Api.Framework.SDK;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Api.Framework.Timers
|
|
{
|
|
/// <summary>
|
|
/// 更新同时队列定时器
|
|
/// </summary>
|
|
public class Update_NoticeQueue : TimerTask
|
|
{
|
|
|
|
private Queue queue = Queue.Synchronized(new Queue());
|
|
public void Add(OrderNoticeEvent e)
|
|
{
|
|
queue.Enqueue(e);
|
|
}
|
|
|
|
public void Add(List<OrderNoticeEvent> e)
|
|
{
|
|
queue.Enqueue(e.ToArray());
|
|
}
|
|
|
|
private object GetData()
|
|
{
|
|
try
|
|
{
|
|
return queue.Dequeue();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
|
|
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public override void Run(object state, bool timeout)
|
|
{
|
|
if (queue.Count > 0)
|
|
{
|
|
var v = GetData();
|
|
while (v!=null)
|
|
{
|
|
EventClient.OnEvent(this, v);
|
|
Thread.Sleep(10);
|
|
//Thread.Sleep(ApiClient.Setting.SystemConfig.timer_send_interval);
|
|
v = GetData();
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|