private void ListenTimer_Elapsed(object sender, ElapsedEventArgs e) { listenTimer.Stop(); try { if (PoolCache.CurrentTask != null && PoolCache.CurrentTask.State == MiningState.Mining) { return; } if (PoolCache.CurrentTask == null && PoolCache.poolTasks.Any()) { PoolCache.CurrentTask = PoolCache.poolTasks.FirstOrDefault(); } PoolCache.poolTasks.Remove(PoolCache.CurrentTask); if (PoolCache.CurrentTask != null && PoolCache.CurrentTask.State == MiningState.Wait) { foreach (Miner miner in PoolCache.WorkingMiners) { try { var tcpstate = new TcpState() { Client = miner.Client, Stream = miner.Stream, Address = miner.ClientAddress }; StartCommand.Send(tcpstate, PoolCache.CurrentTask.CurrentStartMsg); } catch (Exception ex) { LogHelper.Error(ex.ToString()); PoolCache.WorkingMiners.Remove(miner); } } PoolCache.CurrentTask.State = MiningState.Mining; } } catch (Exception ex) { LogHelper.Error(ex.ToString()); } finally { listenTimer.Start(); } }