What you are asking about is called load testing. Depending on what Visual Studio version you are using, there are built-in tools to help you load test your application. See
Visual Studio Load Testing Tools[
^]
If you are using some other version that doesn't have those tools, you should look at
third party load testing tools for .net[
^].
Your other option is to create a unit test application and queue up 30 parallel tasks to hit the database at the same time and use performance counters to measure responses, but this takes a lot more set up than using load testing tools. Some of the ones in the google link may have trial versions that run for some number of days or number of concurrent tests, evaluate each one to find one that meets your needs.
[Edit]
Here is a sample, simple load test you can do:
public class LoadTester
{
List<TimeSpan> times = new List<TimeSpan>();
public void Test()
{
Thread[] threads = new Thread[30];
for (int i = 0; i < 30; i++)
{
threads[i] = new Thread(new ThreadStart(TestDBConn));
threads[i].IsBackground = true;
threads[i].Name = "Test Thread " + i.ToString();
}
for (int i = 0; i < 30; i++)
{
threads[i].Start();
}
bool allFinished = false;
while (!allFinished)
{
allFinished = threads.All(t => t.ThreadState == System.Threading.ThreadState.Stopped);
Thread.Sleep(10);
}
double minMs, maxMs, avgMs, sum;
minMs = double.MaxValue;
maxMs = double.MinValue;
sum = 0.0;
foreach (TimeSpan ts in times)
{
if (ts.TotalMilliseconds < minMs)
minMs = ts.TotalMilliseconds;
if (ts.TotalMilliseconds > maxMs)
maxMs = ts.TotalMilliseconds;
sum += ts.TotalMilliseconds;
}
avgMs = sum / (double)times.Count;
System.Diagnostics.Debug.WriteLine("Max: " + maxMs);
System.Diagnostics.Debug.WriteLine("Min: " + minMs);
System.Diagnostics.Debug.WriteLine("Avg: " + avgMs);
}
public void TestDBConn()
{
Stopwatch sw = new Stopwatch();
sw.Start();
sw.Stop();
times.Add(sw.Elapsed);
}
}
You would put your call to Fecthresultfromdb(name) where it says "Run your test here". I would pull this function out of your form since you only care about the load on the database, the updating of the UI happens in a fixed time, regardless of the number of clients. Its the fetch from the database that will change.
Output will be in the output window.