internal ConnectionThread GetConnectionThread() { ConnectionThread result = null; lock (_lock) { // Search for an available ConnectionThread. foreach (ConnectionThread connectionthread in this._pool) { if (connectionthread.Ready) { if (connectionthread.DbCommand == null) { connectionthread.Ready = false; result = connectionthread; break; } } } // If no available ConnectionThread was found, lets make a new. if (result == null) { Console.WriteLine("New ConnectionThread: " + this._pool.Count); switch (this._databaseconnector) { // New MySQL connector case SNDK.Enums.DatabaseConnector.Mysql: { result = new ConnectionThread(); result.DbConnection = SNDK.DBI.Connector.Mysql.Connect(this); this._pool.Add(result); break; } case SNDK.Enums.DatabaseConnector.Mssql: { result = new ConnectionThread(); result.DbConnection = SNDK.DBI.Connector.Mssql.Connect(this); this._pool.Add(result); break; } } } } return(result); }
public bool Connect() { switch (this._databaseconnector) { case Enums.DatabaseConnector.Mysql: { ConnectionThread thread = new ConnectionThread(); thread.DbConnection = Connector.Mysql.Connect(this); this._pool.Add(thread); break; } case Enums.DatabaseConnector.Mssql: { ConnectionThread thread = new ConnectionThread(); thread.DbConnection = Connector.Mssql.Connect(this); this._pool.Add(thread); break; } } return(this._connected); }
internal ConnectionThread GetConnectionThread() { ConnectionThread result = null; lock (_lock) { // Search for an available ConnectionThread. foreach (ConnectionThread connectionthread in this._pool) { if (connectionthread.Ready) { if (connectionthread.DbCommand == null) { connectionthread.Ready = false; result = connectionthread; break; } } } // If no available ConnectionThread was found, lets make a new. if (result == null) { Console.WriteLine ("New ConnectionThread: "+ this._pool.Count); switch (this._databaseconnector) { // New MySQL connector case SNDK.Enums.DatabaseConnector.Mysql: { result = new ConnectionThread (); result.DbConnection = SNDK.DBI.Connector.Mysql.Connect (this); this._pool.Add (result); break; } case SNDK.Enums.DatabaseConnector.Mssql: { result = new ConnectionThread (); result.DbConnection = SNDK.DBI.Connector.Mssql.Connect (this); this._pool.Add (result); break; } } } } return result; }
public bool Connect() { switch (this._databaseconnector) { case Enums.DatabaseConnector.Mysql: { ConnectionThread thread = new ConnectionThread (); thread.DbConnection = Connector.Mysql.Connect (this); this._pool.Add (thread); break; } case Enums.DatabaseConnector.Mssql: { ConnectionThread thread = new ConnectionThread (); thread.DbConnection = Connector.Mssql.Connect (this); this._pool.Add (thread); break; } } return this._connected; }