/* * if the user pressed on play button */ public void play(string pathCsv) { if (pathCsv.Equals("")) // if path csv not recived { return; } if (puaseFlag) { _manualResetEvent.Set(); puaseFlag = false; return; } t = new Thread(delegate() // new thread for runnung the simulator. { stopFlag = false; while (_simulatorConnectorModel.IsConnected && (IndexLine < _maxLine) && !stopFlag) { _simulatorConnectorModel.Write(_linesArray[IndexLine]); int speedRate = (int)(100 / _speed); // sleep time - according to the speed that the user chose. Thread.Sleep(speedRate); IndexLine++; // update the line (and by that - all the data on the screen will be updated). _manualResetEvent.WaitOne(Timeout.Infinite); } IndexLine = 0; }); t.Start(); }
public void startSimulator() { Thread t = new Thread(delegate() { IuploadFile iuploadFile = new IuploadFile(); string[] lines = iuploadFile.ReadFile(path); int numLines = lines.Length; int i = 0; //while (i < numLines && _simulatorConnector.isConnected) while (i < numLines) { Console.WriteLine(lines[i]); _simulatorConnector.Write(lines[i]); Thread.Sleep(100); i++; } _simulatorConnector.Disconnect(); }); t.Start(); }