private void WriteToDb(TaxFigure record) { using (var provider = new DbProvider <DbMainContext>()) { provider.AddRecord(record); provider.SaveChanges(); Interlocked.Increment(ref _count); } }
private void HandleLine(string line) { var task = _factory.StartNew(() => { if (_canceled) { return; } var record = new TaxFigure(line); if (!record.ValidationErrors.Any()) { WriteToDb(record); } else { Errors.Add(new TaxFigureViewModel(record)); } }); _tasks.Add(task); }