Re: ADO ConnectionTimeout taking 2.3s rather than 1.0s
- From: "Ian Boyd" <admin@xxxxxxxxxxx>
- Date: Fri, 30 Nov 2007 21:50:11 -0500
i am starting the clock just before i call Connection.Open.
Then you are not truly timing the ConnectionTimeout: you are timing the
amount of time it takes for the Connection to acquire a "handle" to the
database server plus the time it takes the ConnectionTimeout to time
out. Again, there is no control over the first part.
Then i guess my question is why do ADO guys implement it so poorly? It's pretty obvious that the first thing they should be doing inside .Open is start a timer:
public void Open(string connectionString, string UserID, string Password)
{
if this.connectionTimeout > 0
{
_connectTimeoutTimer.Interval = this.connectionTimeout * 1000;
_connectTimeoutTimer.Enabled = true;
}
...
}
Our workaround right now is:
EndTime = GetTickCount + Conn.ConnectionTimeout * 1000;
Connection.Open;
while ((!Connection.Active) && (GetTickCount < EndTime)
{
Sleep(10);
}
Yes it would have been nicer to use a timer for a non-busy wait - but that would require an event hander and an event. This is easier because it's inline.
If only MS did it for us.
.
- Follow-Ups:
- Re: ADO ConnectionTimeout taking 2.3s rather than 1.0s
- From: Stephen Howe
- Re: ADO ConnectionTimeout taking 2.3s rather than 1.0s
- From: Bob Barrows [MVP]
- Re: ADO ConnectionTimeout taking 2.3s rather than 1.0s
- Next by Date: Re: ADO ConnectionTimeout taking 2.3s rather than 1.0s
- Next by thread: Re: ADO ConnectionTimeout taking 2.3s rather than 1.0s
- Index(es):
Relevant Pages
|
|