|
-
Jul 12th, 2007, 07:53 AM
#1
Thread Starter
Addicted Member
Threading
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
-
Jul 12th, 2007, 07:56 AM
#2
Re: Threading
You're nuts
-
Jul 12th, 2007, 07:57 AM
#3
Re: Threading
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
-
Jul 12th, 2007, 07:58 AM
#4
Re: Threading
Here is an article about threading probably a good place to start
http://www.startvbdotnet.com/threading/default.aspx
-
Jul 12th, 2007, 08:26 AM
#5
Thread Starter
Addicted Member
Re: Threading
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
-
Jul 12th, 2007, 08:29 AM
#6
Re: Threading
Set the threads IsBackground property to True if you want them to be aborted and disposed immediately when the program is closed.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|