Dictionary<int, BackgroundWorkerInfo> venueBackgroundWorker = new Dictionary<int, BackgroundWorkerInfo>();
protected override void OnStart(string[] args)
{
venueTimer = new System.Timers.Timer(1000);//
venueTimer.Elapsed += new System.Timers.ElapsedEventHandler(VenueTimer_Elapsed);
venueTimer.Enabled = true;
venueTimer.Start();
}
private void VenueTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
venueTimer.Enabled = false;
try
{
VenueService service = new VenueService();
if (venueBackgroundWorker.Count == 0)
{
venueBackgroundWorker = service.InitVenueServices();
}
else
{
Dictionary<int, BackgroundWorkerInfo> removeDic = new Dictionary<int, BackgroundWorkerInfo>();
foreach (var worker in venueBackgroundWorker.Values)
{
if (!worker.worker.IsBusy)
{
removeDic.Add(worker.CompID, worker);
}
}
foreach (var worker in removeDic.Keys)
{
venueBackgroundWorker.Remove(worker);//移除
}
if (venueBackgroundWorker.Count =