private void ReadForward(object sender, EventArgs e) { if (!ReadParameters()) { return; } SetProcessing(true); Log.Info?.Out($"Чтение диска. Side: {Params.Side}. DataRate: {Params.DataRate}."); diskReader = new DiskReader((DiskReaderParams)Params.Clone()); BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += (object sndr, DoWorkEventArgs ee) => { try { if (!diskReader.OpenDriver()) { return; } int successfullyRead = diskReader.ReadForward(); diskReader.CloseDriver(); Log.Info?.Out($"Успешно прочитанных секторов: {successfullyRead}"); } catch (Exception ex) { Log.Error?.Out($"Исключение при чтении диска: {ex.Message} | StackTrace: {ex.StackTrace}"); } }; worker.RunWorkerCompleted += (object sender1, RunWorkerCompletedEventArgs ee) => { SetProcessing(false); }; worker.RunWorkerAsync(); }
private void ReadCatalogue(object sender, EventArgs e) { if (!ReadParameters(false)) { return; } SetProcessing(true); BackgroundWorker worker = new BackgroundWorker(); Log.Info?.Out($"Чтение каталога. DataRate: {Params.DataRate}"); int successfullyRead = 0; DiskReaderParams npars = new DiskReaderParams() { FirstSectorNum = 0, LastSectorNum = 9, DataRate = Params.DataRate, Image = new TrDosImage(9, null), SectorReadAttempts = Params.SectorReadAttempts, Side = DiskSide.Both, CurrentTrackFormat = new TrackFormat(TrackFormatName.TrDosSequential), ReadMode = ReadMode.Standard, TrackLayoutAutodetect = false, UpperSideHeadAutodetect = false, }; diskReader = new DiskReader() { Params = npars }; worker.DoWork += (object sndr, DoWorkEventArgs ee) => { try { if (!diskReader.OpenDriver()) { return; } successfullyRead = diskReader.ReadForward(); diskReader.CloseDriver(); Log.Info?.Out($"Чтение каталога завершено. Успешно прочитанных секторов: {successfullyRead}"); } catch (Exception ex) { Log.Error?.Out($"Исключение при чтении диска: {ex.Message} | StackTrace: {ex.StackTrace}"); } }; worker.RunWorkerCompleted += (object sender1, RunWorkerCompletedEventArgs ee) => { SetProcessing(false); if (MainForm.CatalogueForm == null) { MainForm.CatalogueForm = new CatalogueForm(); } if (successfullyRead > 1) { MainForm.CatalogueForm.ShowForm(diskReader.Params.Image as TrDosImage, false); } }; worker.RunWorkerAsync(); }