public MySQLThread() { instance = this; queryThread = new Thread(new ThreadStart(Execute)); if (!queryThread.IsAlive) { queryThread.Start(); } }
public async Task <TResult> ExecuteThreaded(string query, IDictionary <string, object> parameters, bool debug = false) { this.query = query; this.parameters = parameters; this.debug = debug; MySQLThread mysqlAsync = MySQLThread.GetInstance(); ThreadedId = mysqlAsync.NextId; mysqlAsync.queryCollection.TryAdd(this); while (!mysqlAsync.resultCollection.ContainsKey(ThreadedId)) { await BaseScript.Delay(0); } mysqlAsync.resultCollection.TryRemove(ThreadedId, out dynamic result); return(result); }