1

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

  • is this possible?-
  • what does the constructor string look like? so far mine is: Server=...;Database=...;User ID=...;Password=...;Pooling=True- Do i need to add something enabling asynchronous processing? ("Asynchronous Processing=true" doesnt work)

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);
2
  • 1
    start a different thread using a BackGroundWorker: msdn.microsoft.com/en-us/library/… Commented Jun 24, 2011 at 16:50
  • @davek i dont think i can use BackGroundWorker because it is windows-specific right? (im working with unity) Commented Jun 24, 2011 at 17:19

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.