Results 1 to 2 of 2

Thread: [2008] BackgroundWorker Problem

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member boku's Avatar
    Join Date
    Dec 2004
    Posts
    386

    Post [2008] BackgroundWorker Problem

    I am trying to check URLs for naughty words by using the following

    Imports System
    Imports System.Collections
    Imports System.ComponentModel
    Imports System.Drawing
    Imports System.Threading
    Imports System.Windows.Forms

    Public Class Form1
    Inherits System.Windows.Forms.Form
    Private WithEvents bgw1 As System.ComponentModel.BackgroundWorker
    Dim Reader As New System.IO.StreamReader (Application.StartupPath & "\blacklist.txt")
    Dim textline As String

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Me.bgw1.RunWorkerAsync()
    End Sub

    Public Sub New()
    InitializeComponent()
    End Sub

    Private Sub bgw1_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles bgw1.DoWork
    Dim bgw1 As BackgroundWorker = CType(sender, BackgroundWorker)
    textline = Reader.ReadLine
    Do Until Reader.EndOfStream
    If ComboBox1.Text.Contains(textline) Then
    bgw1.CancelAsync()
    Exit Sub
    Else
    WebBrowser1.Navigate(ComboBox1.Text)
    End If
    Loop
    End Sub

    Private Sub bgw1_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles bgw1.RunWorkerCompleted
    Reader.Close()
    If e.Cancelled Then
    WebBrowser1.Navigate("about:blank")
    End If
    Me.bgw1.RunWorkerAsync()
    End Sub

    End Class
    It is supposed to constantly check the text in the address bar for any words on the "blacklist.txt" without affecting the rest of the form. But it doesn't seem to want to work!

    What am I doing wrong?
    Last edited by boku; May 16th, 2008 at 03:33 AM.
    -BoKu-

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width