Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27349

Multithreading with Fiddler

$
0
0
I really need help with this multithreading problem. I am trying to use FiddlerCore with VB.NET. I don't think you need to understand that to be able to figure out what the problem is. I have been programming in VB for about four years, but have never done multithreading before. Basically, the problem that I am having is that I am trying to add to a list thread safely. Any idea why the code in the FiddlerBeforeRequestHandler is causing it to lock up? All I am trying to do is put data in the URL list and it's taking me FOUR hours to do this EXTREMELY simple task.

Code:

Option Explicit On

Imports Fiddler
'Imports System.Threading

Public Class Form1

    Private URL As List(Of String)

    Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.

        AddHandler FiddlerApplication.BeforeResponse, AddressOf FiddlerBeforeResponseHandler
        AddHandler FiddlerApplication.BeforeRequest, AddressOf FiddlerBeforeRequestHandler

        AddHandler Application.ApplicationExit, AddressOf ShutdownFiddlerApp

        Dim oFlags As FiddlerCoreStartupFlags = FiddlerCoreStartupFlags.Default
        FiddlerApplication.Startup(0, oFlags)
        MsgBox("Started proxy on port " & FiddlerApplication.oProxy.ListenPort)
    End Sub

    Private Sub ShutdownFiddlerApp()
        FiddlerApplication.Shutdown()
        MsgBox("Unloaded proxy")
        Threading.Thread.Sleep(1000)

    End Sub

    Private Sub FiddlerBeforeRequestHandler(ByVal tSession As Session)
        'This part doesn't work
        SyncLock CType(URL, IList).SyncRoot
            URL.Add(tSession.fullUrl)
        End SyncLock
    End Sub

    Private Sub FiddlerBeforeResponseHandler(ByVal tSession As Session)
       
    End Sub

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


Viewing all articles
Browse latest Browse all 27349

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>