I want to build a simple utility to stress test a database application, in short I want to create 500 threads which all run the same query against an SQL database. How do I create the threads?
Thanks
Printable View
I want to build a simple utility to stress test a database application, in short I want to create 500 threads which all run the same query against an SQL database. How do I create the threads?
Thanks
You're nuts :D
VB Code:
Private Sub Button_Click(...) For i As Integer = 1 to 500 Dim StressThread As New Threading.Thread(AddressOf QueryDataBase) StressThread.Start() Next i End Sub Private Sub QueryDataBase() '..Stuff here End Sub
Here is an article about threading probably a good place to start
http://www.startvbdotnet.com/threading/default.aspx
Okay that works great thanks. However, if I run the program a second time it complains about low virtual memory then crashes, presumably becuase theres too many threads still present from the previous time.
Is there any way I can iterate through all the current threads and dispose of them prior to starting again?
I have this
For Each t As Threading.Thread In System.Diagnostics.Process.GetCurrentProcess.Threads
t.Abort()
Next
But it fails with an invalidcastexception
Also I dont obviously want to abort the thread which the ui is running on?
Thanks
Set the threads IsBackground property to True if you want them to be aborted and disposed immediately when the program is closed.