private async Task WriteDown() { if (Writing) { return; } Writing = true; try { while (TraceQueue.TryDequeue(out var item)) { await traceRepository.AddOrUpdate(item.Key, item.HappenTime, item.Datas); } while (PageQueue.TryDequeue(out var item)) { await pageRepository.AddOrUpdate(item.Key, item.HappenTime, item.Datas); } } finally { Writing = false; } }