Asynchronous MySQL

hi there,

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);

I ended up making a separate thread, using BeginInvoke and EndInvoke to carry out the queries

actually the problem in above code is that its not async the way it is.

What you would need to do is put it into a coroutine and then instead of your while, you would have a

yield return iSynch;

in which makes it async.
as the code is now, its not async out of the engines view, because While(…) is blocking, no other code in the whole application can run until it has terminated.

Naturally, if the thread sync is no problem, offloading it to a thread s even better as thats using the other cores that Unity otherwise would barely touch, while it leaves you more power on the one core hammered primarily. Just keep in mind that unity is not threadsafe so you can’t use functions that actually modify unity objects (any UnityEngine.* class) or it will blow up