patrickstrijdonck
Programmer
Hi all,
When Form2 is loading, a background worker is doing the following:
Before, it wasnt even in a background worker and that made my app loading / hanging for about 2 minutes.
now that this is in a background service, the GUI is more responding but the backgroundworker is busy for about 1 / 2 minutes to get this data.
The database is located in the same network, and there are no speed issues in our network.
Can someone take a look at the code and tell me if there is something which can be improved?
Thanks alot for the help.
When Form2 is loading, a background worker is doing the following:
Code:
// TODO: This line of code loads data into the 'iT4DataSet.tblGebruikers' table. You can move, or remove it, as needed.
this.tblGebruikersTableAdapter.Fill(this.iT4DataSet.tblGebruikers);
// TODO: This line of code loads data into the 'iT4DataSet.tblStores' table. You can move, or remove it, as needed.
this.tblStoresTableAdapter.Fill(this.iT4DataSet.tblStores);
// TODO: This line of code loads data into the 'iT4STOCKDataSet.qryOpenOrders' table. You can move, or remove it, as needed.
this.qryOpenOrdersTableAdapter.Fill(this.iT4STOCKDataSet.qryOpenOrders);
// TODO: This line of code loads data into the 'iT4DataSet.qryHomeTasks' table. You can move, or remove it, as needed.
this.qryHomeTasksTableAdapter.Fill(this.iT4DataSet.qryHomeTasks);
// TODO: This line of code loads data into the 'iT4DataSet.tblTasks' table. You can move, or remove it, as needed.
this.tblTasksTableAdapter.Fill(this.iT4DataSet.tblTasks);
// TODO: This line of code loads data into the 'iT4DataSet1.OutstandingCalls' table. You can move, or remove it, as needed.
this.outstandingCallsTableAdapter1.Fill(this.iT4DataSet1.OutstandingCalls);
// TODO: This line of code loads data into the 'iT4STOCKDataSet.tblLeveranciers' table. You can move, or remove it, as needed.
this.tblLeveranciersTableAdapter.Fill(this.iT4STOCKDataSet.tblLeveranciers);
// Getting Row Count for IT Helpdesk Alert!
string selectCount;
string cmdCount = Properties.Settings.Default.IT4ConnectionString1;
selectCount = "SELECT Count(*) FROM OutstandingCalls";
OleDbConnection connCount = new OleDbConnection(cmdCount);
OleDbCommand comCount = new OleDbCommand(selectCount, connCount);
connCount.Open();
Int32 count = Convert.ToInt32(comCount.ExecuteScalar());
this.Invoke((MethodInvoker)delegate
{
textBox7.Text = Convert.ToString(count);
});
//textBox7.Text = Convert.ToString(count);
if (count >= 0)
{
this.Invoke((MethodInvoker)delegate
{
textBox10.Visible = true;
textBox11.Visible = false;
textBox12.Visible = false;
textBox13.Visible = false;
textBox14.Visible = false;
});
}
if (count >= 10)
{
this.Invoke((MethodInvoker)delegate
{
textBox10.Visible = false;
textBox11.Visible = true;
textBox12.Visible = false;
textBox13.Visible = false;
textBox14.Visible = false;
});
}
if (count >= 15)
{
this.Invoke((MethodInvoker)delegate
{
textBox10.Visible = false;
textBox11.Visible = false;
textBox12.Visible = true;
textBox13.Visible = false;
textBox14.Visible = false;
});
}
if (count >= 25)
{
this.Invoke((MethodInvoker)delegate
{
textBox10.Visible = false;
textBox11.Visible = false;
textBox12.Visible = false;
textBox13.Visible = true;
textBox14.Visible = false;
});
}
if (count >= 40)
{
this.Invoke((MethodInvoker)delegate
{
textBox10.Visible = false;
textBox11.Visible = false;
textBox12.Visible = false;
textBox13.Visible = false;
textBox14.Visible = true;
});
}
connCount.Close();
// Get Row Count of open orders
string selectCount2;
string cmdCount2 = Properties.Settings.Default.IT4STOCKConnectionString;
selectCount2 = "SELECT Count(*) FROM qryOpenOrders";
OleDbConnection connCount2 = new OleDbConnection(cmdCount2);
OleDbCommand comCount2 = new OleDbCommand(selectCount2, connCount2);
connCount2.Open();
Int32 count2 = Convert.ToInt32(comCount2.ExecuteScalar());
this.Invoke((MethodInvoker)delegate
{
textBox9.Text = Convert.ToString(count2);
});
connCount2.Close();
// Get Row Count of open tasks
string selectCount3;
string cmdCount3 = Properties.Settings.Default.IT4ConnectionString1;
selectCount3 = "SELECT Count(*) FROM qryOpenTasks";
OleDbConnection connCount3 = new OleDbConnection(cmdCount3);
OleDbCommand comCount3 = new OleDbCommand(selectCount3, connCount3);
connCount3.Open();
Int32 count3 = Convert.ToInt32(comCount3.ExecuteScalar());
this.Invoke((MethodInvoker)delegate
{
textBox8.Text = Convert.ToString(count3);
});
connCount3.Close();
Before, it wasnt even in a background worker and that made my app loading / hanging for about 2 minutes.
now that this is in a background service, the GUI is more responding but the backgroundworker is busy for about 1 / 2 minutes to get this data.
The database is located in the same network, and there are no speed issues in our network.
Can someone take a look at the code and tell me if there is something which can be improved?
Thanks alot for the help.