Пример #1
0
        /// <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);
        }