public ThreadPlotFinalResult(GasBubbleModel model) { this.plotThread = new Thread(model.PlotFinalResults); this.plotThread.IsBackground = false; this.plotThread.Name = "PlotFinalResultThread"; }
public ThreadDdsClient(int cycleTimeMilliseconds, GasBubbleModel model, string serverName, string clientName) { this.Model = model; var task = new Task <Client>(() => { var client = new Client(serverName, clientName); client.Connect(); return(client); }); task.Start(); this.DdsTimer = new Timer(cycleTimeMilliseconds); this.DdsTimer.AutoReset = true; this.DdsTimer.Elapsed += DdsTimerOnElapsed; this.Client = task.Result; }
public ThreadRunSimStep(GasBubbleModel model, int cycleTimeMilliseconds, bool realTime = true, bool printDetails = true) { int counter = 0; this.CycleTime = cycleTimeMilliseconds; this.stopwatch = new Stopwatch(); this.SimThread = new Thread(() => { Console.WriteLine($"Enter thread at {DateTime.Now}"); while (counter <= model.SimParam.SimulationTimeInit / model.SimParam.GlobalTimeStep) { if (IsCancelled) { break; } var elapsedTime = model.Step(counter++); if (printDetails) { Console.WriteLine($"Run {(counter-1)} @ {(counter-1)*model.SimParam.GlobalTimeStep} - {this.stopwatch.ElapsedMilliseconds}: execution time: {elapsedTime} msec."); } this.stopwatch.Restart(); if (elapsedTime < cycleTimeMilliseconds && realTime) { Thread.Sleep(cycleTimeMilliseconds - Convert.ToInt32(elapsedTime)); } } Console.WriteLine($"Exit thread at {DateTime.Now}"); }); this.SimThread.IsBackground = true; this.SimThread.Name = "GasBubbleModelThread"; this.SimThread.Priority = ThreadPriority.Highest; }