private static void Timer_Elapsed(object sender, ElapsedEventArgs e) { if (client == null || client.Connection == null) { throw new TraceStateException("No connection to local db."); } lock (critSec) { List <Log> b = new List <Log>(); foreach (LogBuffer logBuff in Arbiter.ToList()) { b.AddRange(logBuff.Logs); } if (b.Count == 0) { return; } foreach (Log l in b) { Collection.PostAsync <Log>(l); } Arbiter.Clear(); } }
private static void Timer_Elapsed(object sender, ElapsedEventArgs e) { //if (client == null || client.Cluster.Description.State == ClusterState.Disconnected) // throw new TraceStateException("No connection to local db."); lock (critSec) { List <Log> b = new List <Log>(); foreach (LogBuffer logBuff in Arbiter.ToList()) { b.AddRange(logBuff.Logs); } if (b.Count == 0) { return; } Collection.InsertMany(b); Arbiter.Clear(); } }