private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { try { if (hostInstance != null) { List <string> tests = hostInstance.getKey(); foreach (string test in tests) { updateText(tbKeylog, test + "\t"); } hostInstance.GetMouseLocation(out mouseXY); string test2 = mouseXY.X.ToString(); updateContinuesText(lbX, mouseXY.X.ToString()); updateContinuesText(lbY, mouseXY.Y.ToString()); } } catch (Exception ex) { if (backgroundWorker1.IsBusy) { backgroundWorker1.Dispose(); } } }