I was going to disagree with Ian ,

While threads are expensive when traffic is going to block on disk or
network traffic I always think Threads are a good solution. You can minimise
the overhead by creating your own threadpool .

In this case I may be wrong as the initialization cost of your class may be
quite high . It may be more efficient to intialize it once and send the 50
messages in a loop.

Have you run a profiler on the program ? Generally if your CPU is 100% than
threads will not help ( they will make it worse) - If you are not reaching a
high cpu level then threads will help a LOT.

My Hunch ( guess !) is that every time you establish the connection you
incur a network connection logon and arbitration you can reduce the impact
of this with threads (which is what your UNIX people probably did) but you
would be better of setting up the Connection once and then sending all the
messages over the same connection.

You should also note when you are using VPN solutions your network
establishment cost would be much higher depending on solution .

I hope my ramblings make sense. I cant really change yor code as it is VB
and Im a C/C++/C# programer ( I can understand it - just)

Ben


-----Original Message-----
From: Moderated discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED]]On Behalf Of Jesse Sanders
Sent: Tuesday, 11 June 2002 1:44 AM
To: [EMAIL PROTECTED]
Subject: Re: [ADVANCED-DOTNET] Threading is blocking itself or ?


Ian,

Thanks for the reply.  Here is the code for the SOAP class.  I didn't write
the actual soap calls, but instead used the one created by my counterparts
at work.  It would not surprise me if it is the source of the problem.  The
create threads code is straight out of Dan Applemans moving to .Net book.

The soap interface has 4 parameters: timeout, returnaddress, inputdate, and
requestid.

Your help is greatly appreciated... I have been pulling my hair out trying
to get this figured out... nevermind the deadline!

Thanks,

Jesse

Public Class SOAP
    Private Const WRAPPER_ELEMENT_NAMESPACE = "http://tempuri.org/message/";

    Private Const c_strConnectString =
"Provider=SQLOLEDB.1;InitialCatalog=config;" & _
                                "Password=;User
ID=sa;DataSource=172.24.176.167"
    Private Threads() As System.Threading.Thread

    Private m_strServerName As String
    Private m_strRequestType As String
    Private m_strReturnAddress As String
    Private m_strInputXML As String
    Private m_lngRequestID As String
    Private m_strServerIP As String
    Private m_lngTimeout As Long = 5

    Public Sub SendSingleRequest()

        Dim Serializer As MSSOAPLib.SoapSerializer
        Dim Reader As MSSOAPLib.SoapReader
        Dim Connector As MSSOAPLib.SoapConnector

        Dim strSQL As String
        Dim strURL As String

        strURL = "http://"; & m_strServerIP.ToString

        Select Case m_strRequestType
            Case "Fixed Loan", "Fixed Commit", "Price A Loan"
                strURL = strURL & "GfsReq.asp"
            Case "Update Grid"
                strURL = strURL & "Grids.asp"
            Case "Rate Sheet"
                strURL = strURL & "RateSheet.asp"
            Case "Pair Off"
                strURL = strURL & "PairOff.asp"
        End Select


        Try
            '-- Set up the connector
            Connector = New MSSOAPLib.HttpConnector()
            Connector.Property("EndPointURL") = strURL
            Connector.Property("Timeout") = 6000000
            Connector.BeginMessage() 'Nothing

            '-- Set up the Serializer
            Serializer = New MSSOAPLib.SoapSerializer()
            Serializer.Init(Connector.InputStream)
            Serializer.startEnvelope()
            Serializer.startBody()

            Select Case m_strRequestType
                Case "Fixed Loan", "Fixed Commit", "Price A Loan"
                    Serializer.startElement("CalculatePrice",
WRAPPER_ELEMENT_NAMESPACE, , "m")
                Case "Update Grid"
                    Serializer.startElement("UpdateGrid",
WRAPPER_ELEMENT_NAMESPACE, , "m")
                Case "Rate Sheet"
                    Serializer.startElement("RequestRateSheet",
WRAPPER_ELEMENT_NAMESPACE, , "m")
                Case "Pair Off"
                    Serializer.startElement("CalculatePairOff",
WRAPPER_ELEMENT_NAMESPACE, , "m")
            End Select

            Serializer.startElement("TimeOut")
            Serializer.writeString(m_lngTimeout)
            Serializer.endElement()

            Serializer.startElement("ReturnAddress")
            Serializer.writeString(m_strReturnAddress)
            Serializer.endElement()

            Serializer.startElement("InputData")
            Serializer.writeString(m_strInputXML)
            Serializer.endElement()

            Serializer.startElement("RequestID")
            Serializer.writeString(m_lngRequestID)
            Serializer.endElement()
            Serializer.endElement()
            Serializer.endBody()
            Serializer.endEnvelope()
            Connector.EndMessage()

            Reader = New MSSOAPLib.SoapReader()
            Reader.Load(Connector.OutputStream)
        Catch E As Exception
            EventLog.WriteEntry("GFSSoap.SOAP", E.Message, _
                     EventLogEntryType.Error, 1, 1)
        End Try

        Exit Sub

    End Sub

    Public Sub New(ByVal strServerName As String, _
                    ByVal strRequestType As String, _
                    ByVal strReturnAddress As String, _
                    ByVal strInputXML As String, _
                    ByVal lngRequestID As String, _
                    ByVal strServerIP As String)
        m_strServerName = strServerName
        m_strRequestType = strRequestType
        m_strReturnAddress = strReturnAddress
        m_strInputXML = strInputXML
        m_lngRequestID = lngRequestID
        m_strServerIP = strServerIP
    End Sub

    Protected Overrides Sub Finalize()
        MyBase.Finalize()
    End Sub

    Public Sub StartThreads(ByVal ThreadCount As Integer)
        Dim Idx As Integer

        If ThreadCount < 1 Then ThreadCount = 1
        ReDim Threads(ThreadCount - 1)
        Try
            For Idx = 0 To ThreadCount - 1
                Threads(Idx) = New Threading.Thread(AddressOf
Me.SendSingleRequest)
                Threads(Idx).Priority =
System.Threading.ThreadPriority.BelowNormal
                Threads(Idx).IsBackground = True
                Threads(Idx).Start()
            Next
        Catch E As Exception
            EventLog.WriteEntry("GFSSoap.SOAP", E.Message, _
                     EventLogEntryType.Error, 1, 1)
        End Try
    End Sub
End Class

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