Sure thing Mohammed,
Here's the code. This code does not contain the distruction of the
connection though, but feel free to wrap it in a Using(..) { } statement if
you like.
public class ConsoleApplication
{
private string connectionString = "Address=.; Database=Northwind;
Trusted_Connection=true; Max Pool Size=30; Min Pool Size=1; Pooling=True";
private int count;
[STAThread]
public static void Main(string[] args)
{
try
{
ConsoleApplication ca = new ConsoleApplication();
ca.Begin(100);
}
catch(Exception ex)
{
Console.WriteLine(ex.ToString());
}
finally
{
Console.WriteLine("App Execution Complete.");
Console.Read();
}
}
public void Begin(int frequency)
{
for(int i = 0; i < frequency; i++)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(this.Work));
// Simulate rest : you can raise this if you like
Thread.Sleep(100);
}
}
public void Work(object param)
{
SqlConnection connection = new SqlConnection(this.connectionString);
SqlCommand command = new SqlCommand("Select * from Customers",
connection);
command.CommandType = CommandType.Text;
DataSet dsData = new DataSet();
new SqlDataAdapter(command).Fill(dsData);
Console.WriteLine("{0} - DB Job complete", Interlocked.Increment(ref
this.count));
}
}
"Mohamoss" <mohamed.mossad (AT) egdsc (DOT) microsoft.com> wrote
Quote:
Hi Cordell
this seems to be something other than the exepected behavior , would you
send the sample application that you did your test on please
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC |