/// <summary> /// The button clear log is pressed, go and clear the log, display a progress in the meanwhile /// </summary> private void btnEraseLogging_Click(object sender, EventArgs e) { //Just to be sure, check if we have an open device if (canSbsDevice == null) { return; } //Make sure the user knows and is sure if (MessageBox.Show("This BBMS log is about to be erased.\r\nAre you sure?", "Erase log", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { return; } //Create an interface to the logfile Logfile logfile = new Logfile(canSbsDevice); //A dialog is created that displays the readout progress. //The shown event of the dialog is used to start a task that actually reads the log and updates the dialog text and progress bar. BmsProgressStatus waitDialog = new BmsProgressStatus(); waitDialog.Shown += (se, ev) => { Task tsk = new Task(delegate { logfile.ClearLog(waitDialog); }); tsk.Start(); }; waitDialog.ShowDialog(this); }
/// <summary> /// The button read log is pressed, go and read the log, display a progress in the meanwhile /// </summary> private void btnReadLogging_Click(object sender, EventArgs e) { //Just to be sure, check if we have an open device if (canSbsDevice == null) { return; } //Create an interface to the logfile Logfile logfile = new Logfile(canSbsDevice); //A dialog is created that displays the readout progress. //The shown event of the dialog is used to start a task that actually reads the log and updates the dialog text and progress bar. //An events list is returned when finished IEvent[] events = null; BmsProgressStatus waitDialog = new BmsProgressStatus(); waitDialog.Shown += (se, ev) => { Task tsk = new Task(delegate { //Actual reading function for events logfile.ReadLog(out events, waitDialog, true); }); tsk.Start(); }; waitDialog.ShowDialog(this); Events dlg = new Events(); dlg.events = events; dlg.ShowDialog(this); }