public void Connect(string login, string password, ConnectionDelegate connUpdateHandler, PriceUpdateDelegate PriceUpdateHandler, DataUpdateDelegate DataUpdateHandler) { _username = login; _password = password; if (connUpdateHandler != null) { ConnectionStatusEvent += connUpdateHandler; } if (PriceUpdateHandler != null) { PriceUpdateEvent += PriceUpdateHandler; } if (DataUpdateHandler != null) { DataUpdateEvent += DataUpdateHandler; } var marketFeedThread = new Thread(Initialize) { IsBackground = true, Name = "TT API Thread" }; marketFeedThread.Start(); }
public void RunTest(DataUpdateDelegate graphUpdate, float stopVoltage, int readingDelay, int stepSize, string outFile) { TestRunner runner = new TestRunner(graphUpdate, stopVoltage, readingDelay, stepSize, outFile); Thread tThread = new Thread(new ThreadStart(runner.RunTest)); KeepRunningTest = true; tThread.Start(); }
public void GenerateBalanceKeithleyCalibrationData(DataUpdateDelegate graphUpdate, float stopValue, int readingDelay, int stepSize, string outFile) { CalibrationRunner runner = new CalibrationRunner(graphUpdate, stopValue, readingDelay, stepSize, outFile); Thread tThread = new Thread(new ThreadStart(runner.RunTest)); KeepRunningTest = true; tThread.Start(); }
public FormMain() { this.mDateUpdater = new DataUpdateDelegate(this.UpdateDataBar); InitializeComponent(); ReadConfig(); if (mConfig.show_brake) { panelBrakeLightRight.Show(); panelBrakeLightLeft.Show(); panelBrakeLightLeft.BackColor = Color.FromName("Maroon"); panelBrakeLightRight.BackColor = Color.FromName("Maroon"); } else { panelBrakeLightRight.Hide(); panelBrakeLightLeft.Hide(); } }
void ProcessUpdate(WatcherChangeTypes changeType) { lock (_syncRoot) { // File created, deleted, or first call, setup the reader. if (_fileStream == null || changeType == WatcherChangeTypes.Deleted || changeType == WatcherChangeTypes.Created) { if (_reader != null) { _reader.Dispose(); _reader = null; } if (_fileStream != null) { _fileStream.Dispose(); _fileStream = null; } if (changeType == WatcherChangeTypes.Deleted) { return; } try { _fileStream = new FileStream(FilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); _reader = new StreamReader(_fileStream); } catch (Exception ex) { SystemMonitor.Error(ex.Message); _reader = null; _fileStream.Dispose(); _fileStream = null; } } if (_fileStream == null || _fileStream.CanRead == false) { return; } if (_fileStream.Length < _lastFilePos - 10) {// File was rewritten start from beggining. _lastFilePos = 0; } try { _fileStream.Seek(_lastFilePos, SeekOrigin.Begin); string line = _reader.ReadLine(); while (line != null) { DataUpdateDelegate delegateInstance = NewLineReadEvent; if (delegateInstance != null) { delegateInstance(this, line); } line = _reader.ReadLine(); } } catch (Exception ex) { SystemMonitor.OperationError("Failed to read file", ex); } _lastFilePos = _fileStream.Position; } }
public TestRunner(DataUpdateDelegate graphUpdate, float stopVoltage, int readingDelay, int stepSize, string outFile) { GraphUpdate = graphUpdate; StopVoltage = stopVoltage; ReadingDelay = readingDelay; StepSize = stepSize; OutFile = outFile; }