private void GetReadingsFromFile(string filePath) { try { _readingsFromFile.Clear(); StreamReader fs = new StreamReader(filePath); string s = ""; while (s != null) { s = fs.ReadLine(); if (!string.IsNullOrEmpty(s)) { var read = ReadingsListener.MappRead(s); if (read != null) { _readingsFromFile.Add(read); } } } } catch (Exception ex) { Debug.WriteLine(string.Format("{0}: {1}\n{2}", nameof(GetReadingsFromFile), ex.Message, ex.StackTrace)); } }
private void StartReading(Reading reading) { reading.CancellationTokenSource = new CancellationTokenSource(); reading.IsConnected = null; reading.Task = new Task(() => { var _readsListener = new ReadingsListener(reading.Reader.Host, int.Parse(reading.Reader.Port), reading.Reads, reading.CancellationTokenSource, reading); _readsListener.StartReading(); }); if (reading.StartedDateTime == null) { reading.StartedDateTime = DateTime.UtcNow; } reading.Task.Start(); }