Ted
Ted

Reputation: 31

Asynchronous MySQL

im trying to make an asynchronous connection to a MySQL database to avoid my application from freezing up. I was wondering:

have you ever done this? ANY help is appreciated. thanks so much!!!

for reference, this is basically what im trying to accomplish (C#):

cmd = new MySqlCommand(query, con); 
    IAsyncResult iSynch;
    iSynch= cmd.BeginExecuteReader();
    while(!iSynch.IsCompleted){
        print("loading loading loading");
    }
    rdr = cmd.EndExecuteReader(iSynch);

Upvotes: 1

Views: 1151

Answers (1)

Blindy
Blindy

Reputation: 67380

Actually the code you're proposing would still freeze your application until the processing is done.

The way to do this is to spawn a second thread that does the querying and the ui update (through Invoke), leaving the first thread free to process windows messages.

Upvotes: 4

Related Questions