My application freeze when loading information from my database
Posted by: Dylan Bastiaanse
Date: May 13, 2016 05:09AM

Hello, i have a annoying bug when i try to reach the database server, my application freeze.

I have searched and come down with the background worker and i done it but it keeps freezing for a couple seconds.

You have a great help voor me earlier so i hope that you guys can help me.

private readonly BackgroundWorker worker = new BackgroundWorker();


private void Window_Loaded(object sender, RoutedEventArgs e)
{
worker.DoWork += worker_DoWork;
worker.RunWorkerCompleted += worker_RunWorkerCompleted;
worker.RunWorkerAsync();
}

private void worker_DoWork(object sender, DoWorkEventArgs e)
{
Dispatcher.Invoke(new Action(() =>
{
conn4.Open();
MySqlCommand cmd = new MySqlCommand("Select ID,Voornaam,Achternaam,Gebruikersnaam,Wachtwoord,Email,Taal from Gebruikers", conn);
MySqlDataAdapter adp = new MySqlDataAdapter(cmd);
DataSet ds = new DataSet();
adp.Fill(ds, "LoadDataBinding");
dataGridCustomers.DataContext = ds;
conn4.Close();
label.Content = dataGridCustomers.Items.Count - (1);
int number = Convert.ToInt32(label.Content);
number = number + 1;
label.Content = number.ToString();
}));
}

private void worker_RunWorkerCompleted(object sender,
RunWorkerCompletedEventArgs e)
{
//checking for username and email
}

Sorry for my bad english.

Greetings from the Netherlands.

Options: ReplyQuote


Subject
Written By
Posted
My application freeze when loading information from my database
May 13, 2016 05:09AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.