using System;
using System.Data;
using MySql.Data.MySqlClient;
using System.Threading;
namespace MySqlTest
{
public delegate void hello();
///
/// Summary description for Class1.
///
class Class1
{
///
/// The main entry point for the application.
///
static string connStr = "Data Source=127.0.0.1;Database=Armada;User id=armada;Password=armada;pooling=false";
[STAThread]
static void Main(string[] args)
{
hello h = new hello(makeConnection);
//Thread[] thread = new Thread[300];
for (int i=0; i < 300; i++)
{
//thread[i] = new Thread(new ThreadStart(makeConnection));
//Thread.Sleep(33);
//thread[i].Start();
h.BeginInvoke(null, null);
}
Console.ReadLine();
for (int i=0; i < 300; i++)
{
//thread[i] = new Thread(new ThreadStart(makeConnection));
//thread[i].Start();
h.BeginInvoke(null, null);
}
Console.ReadLine();
}
private static void makeConnection()
{
try
{
MySqlConnection conn = new MySqlConnection( connStr );
Console.WriteLine("Opening connection "+Thread.CurrentThread);
conn.Open();
MySqlCommand cmd = conn.CreateCommand();
cmd.CommandText = "select * from assetlist";
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
da.Fill(new DataTable());
Console.WriteLine("Closing connection "+Thread.CurrentThread);
conn.Close();
Console.WriteLine("Opening connection "+Thread.CurrentThread);
conn.Open();
cmd = conn.CreateCommand();
cmd.CommandText = "select * from pernodeassetlist";
da = new MySqlDataAdapter(cmd);
da.Fill(new DataTable());
Console.WriteLine("Closing connection "+Thread.CurrentThread);
conn.Close();
Console.WriteLine("Opening connection "+Thread.CurrentThread);
conn.Open();
cmd = conn.CreateCommand();
cmd.CommandText = "select * from assetlist";
da = new MySqlDataAdapter(cmd);
DataTable t = new DataTable();
da.Fill(t);
Console.WriteLine(t.Rows.Count);
Console.WriteLine("Closing connection "+Thread.CurrentThread);
conn.Close();
}
catch(Exception e)
{
Console.WriteLine(e.Message);
}
}
}
}