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-----
From: Moderated discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED]]On Behalf Of Jesse Sanders
Sent: Sunday, 9 June 2002 6:53 AM
To: [EMAIL PROTECTED]
Subject: [ADVANCED-DOTNET] Threading is blocking itself or ?


 Hi all,

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.

You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to