Tuesday, May 24, 2011
How to solve problem “Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.”
How to
solve problem “Timeout expired. The timeout period elapsed prior to
obtaining a connection from the pool. This may have occurred because all pooled
connections were in use and max pool size was reached.”
Reason:
Usually do not close its
associated connection when use a DataReader.
Three ways to solve:
1 SqlDataReader sdr =
sCmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
2 Explicitly close the connection
sc.Close();
3 Using block
using (SqlConnection sc = new SqlConnection(connString))
{
SqlCommand sCmd = new SqlCommand("SELECT * FROM Shippers", sc);
sc.Open();
Console.WriteLine("Conns opened " + i.ToString());
SqlDataReader sdr =
sCmd.ExecuteReader();
sdr.Close();
}
Using Task in ASP.NET MVC Today
http://devhawk.net/2011/05/19/using-task-of-t-in-asp-net-mvc-today/
Each major release of .NET to date has introduced a new async API pattern. .NET 1.0 had the Async Programming Model (APM). .NET 2.0 introduced the Event-based Async Pattern (EAP). Finally .NET 4.0 gave us the Task Parallel Library (TPL). The await keyword only works with APIs writen using the TPL pattern. APIs using older async patterns have to be wrapped as TPL APIs to work with await. The Async CTP includes a bunch of extension methods that wrap common async APIs, such as DownloadStringTaskAsync from the code above.
Each major release of .NET to date has introduced a new async API pattern. .NET 1.0 had the Async Programming Model (APM). .NET 2.0 introduced the Event-based Async Pattern (EAP). Finally .NET 4.0 gave us the Task Parallel Library (TPL). The await keyword only works with APIs writen using the TPL pattern. APIs using older async patterns have to be wrapped as TPL APIs to work with await. The Async CTP includes a bunch of extension methods that wrap common async APIs, such as DownloadStringTaskAsync from the code above.
Subscribe to:
Posts (Atom)