public MainWindow() { InitializeComponent(); MPUSB.OpenMPUSBDevice(); bw.WorkerSupportsCancellation = true; bw.WorkerReportsProgress = true; bw.DoWork += Bw_DoWork; bw.ProgressChanged += Bw_ProgressChanged; bw.RunWorkerAsync(); pgbIngang1.Value = Convert.ToInt16(MPUSB.ReadAnalogIn(1)); pgbIngang2.Value = Convert.ToInt16(MPUSB.ReadAnalogIn(0)); }
private void Bw_DoWork(object sender, DoWorkEventArgs e) { AnalogOutput data = new AnalogOutput(); do { System.Threading.Thread.Sleep(500); data.Potent1 = MPUSB.ReadAnalogIn(1); data.Potent2 = MPUSB.ReadAnalogIn(0); data.LightSensor = MPUSB.ReadAnalogIn(3); bw.ReportProgress(100, data); }while (!bw.CancellationPending); e.Cancel = true; }