public PostgresThread()
 {
     instance    = this;
     queryThread = new Thread(new ThreadStart(Execute));
     if (!queryThread.IsAlive)
     {
         queryThread.Start();
     }
 }
Esempio n. 2
0
        public async Task <TResult> ExecuteThreaded(string query, IDictionary <string, object> parameters, bool debug = false)
        {
            Query      = query;
            Parameters = parameters;
            Debug      = debug;
            PostgresThread postgresAsync = PostgresThread.GetInstance();

            ThreadedId = postgresAsync.NextId;
            postgresAsync.queryCollection.TryAdd(this);

            while (!postgresAsync.resultCollection.ContainsKey(ThreadedId))
            {
                await BaseScript.Delay(0);
            }

            postgresAsync.resultCollection.TryRemove(ThreadedId, out dynamic result);

            return(result);
        }