Problem in thread Abort RRS feed

  • Question

  • Hi there this is my first program in multi-threading i am just learning it  but i am having issues in thread abort

    here is my code

    Dim extract As System.Threading.Thread
    Private Delegate Sub newupdate()
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim extract As New System.Threading.Thread(AddressOf geturls)
            extract.IsBackground = True
        End Sub
    Public Sub geturls()
            If InvokeRequired Then
                BeginInvoke(New newupdate(AddressOf geturls))
                For i = 0 To NumericUpDown1.Value
                    WebBrowser1.Document.Window.ScrollTo(New Point(0, WebBrowser1.Document.Body.ScrollRectangle.Height))
            End If
        End Sub

    i am learning so i tried to make a simple app that just scrolls web browser but its not working 

    here is what i am using to abort my thread


    vinay pant

    Monday, October 12, 2015 2:06 AM


  • You seem to have a variable "extract" declared as global variable.

    And you again declare and initialize the same name "extract" variable inside a method "Button1_Click". The scope of this variable within the method is valid only inside this method. So if you are trying to abort the thread using the variable "extract" outside this method, it wouldn't be valid.

    • Marked as answer by repulsive1 Wednesday, November 18, 2015 3:58 PM
    Thursday, November 12, 2015 7:08 AM