Created
September 18, 2012 22:40
-
-
Save naraga/3746449 to your computer and use it in GitHub Desktop.
What happens when sql connections runs out? You are gonna wait
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
// connection pool "overflow" demo | |
private const int ConnSize = 150; | |
static void Main(string[] args) | |
{ | |
var connections = new SqlConnection[ConnSize]; | |
for (int i = 0; i < ConnSize; i++) | |
{ | |
connections[i] = new SqlConnection("Data source=bb5\\bb5;Initial Catalog=chatode;Integrated Security=SSPI; Async=True"); | |
connections[i].Open(); | |
var cmd = new SqlCommand("select * from TheInteger", connections[i]); | |
IAsyncResult r = cmd.BeginExecuteReader(); | |
Console.WriteLine("conn {0}", i); | |
} | |
Console.ReadLine(); | |
for (int i = 0; i < 100; i++) | |
{ | |
connections[i].Close(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment