public void FillThreadWork() { while (TraceLog.CurrentDBSize() < StartingDBSize) { Log l = new Log(LogLevel.DEBUG, "01/03/2018 11:36:25 GenericRegulator REG-PRESS-FLUX-P2 False Regolatore Arrestato. 1 5"); LogManager.TraceLog.Write(l); } }
/// <summary> /// Starts the specified benchmark by this class /// </summary> /// <param name="collectionName"></param> public override void Start(string collectionName) { try { LogManager.TraceLog.Connect(collectionName); } catch (TraceLogStateException e) { } TraceLog.Write(new Log(LogLevel.CRITICAL, "")); TraceLog.Flush(); //collection has not the preferred size to operate with if (TraceLog.CurrentDBSize() < StartingDBSize) { //Start 5 threads to write continuonsly until the desired size is reached List <Task> fillTasks = new List <Task>(); for (int i = 0; i < 200; i++) { fillTasks.Add(Task.Factory.StartNew(FillThreadWork)); } Task.WaitAll(fillTasks.ToArray()); } List <Task> tasks = new List <Task>(); //timer.Interval = this.Resolution; timer.Elapsed += Timer_Elapsed; //Starts the only thread for this kind of benchmark for (int i = 0; i < this.ThreadNumber; i++) { tasks.Add(Task.Factory.StartNew(ThreadWork)); } //timer.Start(); //Launch the only thread Task.WaitAll(tasks.ToArray()); //timer.Stop(); sw.Close(); Finished = true; }