Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Collision with simultaneous hits
Message
De
18/11/2013 21:36:46
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Collision with simultaneous hits
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01588296
Message ID:
01588296
Vues:
49
I am enhancing a testing tool to send some hits against a Web server. The code initializes two instances of the class:
    Private oInternet As Framework.Internet = Nothing
    Private oInternet2 As Framework.Internet = Nothing
In the form Load() event, I have this:
        oInternet = New Framework.Internet(oApp)
        oInternet2 = New Framework.Internet(oApp)
Then, in a button of the form, I am issuing the startup of two timers where they each have a timer event including something like this:
        ' Get the URL
        oInternet.cUrl = LoadTestUrl.Text
        If Not oInternet.GetUrl() Then
        End If
        ' Get the URL
        oInternet2.cUrl = LoadTestUrl2.Text
        If Not oInternet2.GetUrl() Then
        End If
In the Internet class, I have something like this (simplified here just for the basis of explaining the situation):
    Public cHTML As String = ""
    Public oCookieContainer As System.Net.CookieContainer = New System.Net.CookieContainer

    ' Get the HTML response from a server
    Public Function GetUrl() As Boolean
        Dim lcUrl As System.Uri = Nothing
        Dim llSuccess As Boolean = False
        Dim loHttpWebRequest As System.Net.HttpWebRequest = Nothing
        Dim loStream As System.IO.Stream = Nothing
        Dim loString As System.IO.StreamReader = Nothing
        Dim loWebResponse As System.Net.WebResponse = Nothing

        ' Reset the values
        cHTML = ""

        ' Make it into a Uri
        lcUrl = New System.Uri(cUrl)

        ' Make it into a Web request
        loHttpWebRequest = System.Net.HttpWebRequest.Create(lcUrl)

        ' Assign the cookie container
        loHttpWebRequest.CookieContainer = oCookieContainer

        Try
            loWebResponse = loHttpWebRequest.GetResponse()
            loStream = loWebResponse.GetResponseStream()
            loString = New System.IO.StreamReader(loStream)
            cHTML = loString.ReadToEnd()
            llSuccess = True
        Catch loError As Exception
            cMessage = loError.Message
        End Try

        Return llSuccess
    End Function
If I only use one timer, thus sending only one URL in sequence, this works. As soon as I use two timers, they collapse on each other. Those are two instances of the class. Anyone knows why they would collapse on each other?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform