private void BgwTasklist_DoWork(object sender, DoWorkEventArgs e) { try { if (GlobalProperties.DatabaseStatus) { dtTasklist = DB_SFDB.PopulateTasklist(); } } catch (Exception m) { Error.Collect(m.StackTrace.ToString()); Debug.WriteLine(m); } }
private void BgwTasklist_DoWork(object sender, DoWorkEventArgs e) { while (true) { try { if (PublicProperties.DatabaseStatus) { dtTasklist = DB_SFDB.PopulateTasklist(); BeginInvoke((MethodInvoker) delegate { try { dgvTasklist.Rows.Clear(); int row = 0; foreach (DataRow dr in dtTasklist.Rows) { dgvTasklist.Rows.Add(dr.ItemArray); dgvTasklist.Rows[row].Cells[0].Value = row + 1; row += 1; } } catch { } }); } } catch (Exception m) { Error.Collect(m.StackTrace.ToString()); Debug.WriteLine(m); } Thread.Sleep(2000); } }