public double shine() { //Make sure the traces collection for the LightSource is assigned some traces this.createStartTracesOnEmpty(); //starting timer DateTime startTime = DateTime.Now; this.calculateTotalIntensity(); int tcount = this.traceCount(); /* CODE BELOW SHOULD REPLACE OLD NON_THREADED ROUTINE: * foreach (Scientrace.Trace trace in this.traces) { * trace.cycle(); * } */ this.bar = new ConsoleActivityStatusBar(100, tcount); //create a stack with all traces, to be popped by thread processes below. this.traceStack = new Stack <Scientrace.Trace>(this.traces); List <Thread> threads = new List <Thread>(); //number threads from 0 to lightsource_shine_threads - 1 for (int iThread = 0; iThread < this.lightsource_shine_threads; iThread++) { Thread stackPopThread = new Thread(this.emptyStack); stackPopThread.Start(); threads.Add(stackPopThread); Thread.Sleep(50); } foreach (Thread aThread in threads) { //Wainit for all threads to finish aThread.Join(); } bar.closeBar(); //stopping timer DateTime stopTime = DateTime.Now; this.shine_duration = (stopTime - startTime); /* if (this.lightsource_shine_threads > 1) { * Console.Write("Several threads have been active, need some time to sync..."); * Thread.Sleep(500); * Console.WriteLine(" [done]"); * }*/ this.addObjectRevenues(); return(this.total_lightsource_intensity); }
public double shine() { //Make sure the traces collection for the LightSource is assigned some traces this.createStartTracesOnEmpty(); //starting timer DateTime startTime = DateTime.Now; this.calculateTotalIntensity(); int tcount = this.traceCount(); /* CODE BELOW SHOULD REPLACE OLD NON_THREADED ROUTINE: foreach (Scientrace.Trace trace in this.traces) { trace.cycle(); } */ this.bar = new ConsoleActivityStatusBar(100, tcount); //create a stack with all traces, to be popped by thread processes below. this.traceStack = new Stack<Scientrace.Trace>(this.traces); List<Thread> threads = new List<Thread>(); //number threads from 0 to lightsource_shine_threads - 1 for (int iThread = 0; iThread < this.lightsource_shine_threads; iThread++) { Thread stackPopThread = new Thread(this.emptyStack); stackPopThread.Start(); threads.Add(stackPopThread); Thread.Sleep(50); } foreach (Thread aThread in threads) { //Wainit for all threads to finish aThread.Join(); } bar.closeBar(); //stopping timer DateTime stopTime = DateTime.Now; this.shine_duration = (stopTime-startTime); /* if (this.lightsource_shine_threads > 1) { Console.Write("Several threads have been active, need some time to sync..."); Thread.Sleep(500); Console.WriteLine(" [done]"); }*/ this.addObjectRevenues(); return this.total_lightsource_intensity; }