The priority thing is likely to be a significant issue here - the UI thread will be running with default priority. This suggests that your For loop will get as far as creating one thread, and then will be pre-empted to allow that thread to run to completion. It would not be surprising if your code only executed one call at at time.
However, I would go further than Ben's suggestion of changing priorities, and say that you are doing this in entirely the wrong way. Creating a thread to do perform just a single request and then exit is horrifically inefficient. Threads are expensive, thread creation particularly so. So this is a really bad way of doing this. What does your SendSingleRequest method look like? I ask because this will determine how you might go about fixing the code. If the method calls it makes are also available in asynchronous form then use those. (E.g. if you are using the Socket class, then all of the blocking methods such as Send, Accept and Receive have asynchronous equivalents - BeginSend, BeginAccept, BeginReceive etc.) This means that you don't have one thread per request - a single thread can launch many requests. Alternatively use the system thread pool to queue up multiple requests. The only problem with that is that you won't be able to launch more than 25*(no. of CPUs in your machine) simultaneous requests because the thread pool is capped. One other question: does SendSingleRequest attempt to do anything whatsoever with any of the controls on your form? -- Ian Griffiths DevelopMentor ----- Original Message ----- From: "Jesse Sanders" <[EMAIL PROTECTED]> > Ben, > > Thanks for the tip on the priority. I had just set it back to below normal > to try to test this morning. I just haven't made it into work yet to try > it. The threadcount is set by the value in the txtThreadcount textbox. > > Any other tips? Do you see anything else that looks wrong with my code? > > Thanks, > > Jesse > > > -----Original Message----- > > From: Ben Kloosterman > > > > I would never use Priority.Highest except for small > > threads( and I woould set the priority back afterwards) > > it may set things at a higher priority then .NET or the OS! > > > > If you use priorities and Threading be-carefull it is the > > easiest way to deadlock yourself. > > > > I program in C# and dont understand how > > txtConcurrentRequests gets intitialised . > > ThreadCount = Val(txtConcurrentRequests.Text) > > > > Ben > > > > -----Original Message----- > > Jesse Sanders wrote: > > > > I searched the archives on threading, but I didn't see > > anything close to my > > problem. What I am trying to do is send 100 SOAP requests to > > a server at > > once to stress test it. I wrote it originally in VB6, but > > the requests were > > getting backjammed, so I turned to VB.Net to solve this issue. > > > > I have a SOAP class called SOAP, which sends the soap request > > to the server. > > The soap class takes 6 parameters, so I included them in the > > constructor. > > The constructor sets 6 private member variables with the incoming > > parameters. > > > > I don't get any errors compile time or runtime, but when I > > specify 1 or 100 > > concurrent requests, it might send 0 - 4 requests to the > > server. I'm not > > sure what I am doing wrong, but I know it has to do with the > > threading part. > > The code works fine without threading, but then gets freaky > > when its in > > place. > > > > Any help is appreciated. > > > > Thanks, > > > > Jesse Sanders > > > > Code Snippet: > > > > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As > > System.EventArgs) Handles Button1.Click > > Dim oSoap() As SOAPTest.Class1 > > Dim strServer As String > > Dim strServerIP As String > > Dim strInputXML As String > > Dim strRequestType As String > > Dim ThreadCount As Integer > > Dim lngRequestID As Long > > > > Dim selectedIndex As Integer > > Dim selectedItem As Object > > > > Dim Threads() As System.Threading.Thread > > > > strServer = txtServer.Text > > strServerIP = txtServerIP.Text > > strInputXML = txtInputXML.Text > > > > selectedIndex = cboRequestType.SelectedIndex > > selectedItem = cboRequestType.SelectedItem > > strRequestType = selectedItem.ToString() > > ThreadCount = Val(txtConcurrentRequests.Text) > > > > If ThreadCount < 1 Then ThreadCount = 1 > > ReDim Threads(ThreadCount - 1) > > > > Dim Idx As Integer > > lngRequestID = 1234 > > > > ReDim oSoap(ThreadCount - 1) > > > > For Idx = 0 To ThreadCount - 1 > > > > oSoap(Idx) = New SOAPTest.Class1(strServer, > > strRequestType, "", > > strInputXML, lngRequestID, strServerIP) > > > > Threads(Idx) = New Threading.Thread(AddressOf > > oSoap(Idx).SendSingleRequest) > > Threads(Idx).Priority = > > System.Threading.ThreadPriority.Highest > > Threads(Idx).IsBackground = True > > Threads(Idx).Start() > > lngRequestID = lngRequestID + 1 > > Next > > > > MessageBox.Show("Done: Sent " & ThreadCount & " requests") > > End Sub You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.