Пример #1
0
 public MySQLThread()
 {
     instance    = this;
     queryThread = new Thread(new ThreadStart(Execute));
     if (!queryThread.IsAlive)
     {
         queryThread.Start();
     }
 }
Пример #2
0
        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);
        }