Error when using BackgroundWorker in Windows Service

I am running the following code as a windows service.  Or trying to.  I just need to have a couple of seperate threads running.  I usually do it with in a windows form with no problem, but when I try to compile this code, I get an error.    "Handles clause requres a WithEvents variable defined in the containing type or one of its base types"


**********************
Imports System.IO
Imports System.Diagnostics
Imports System.Text

Public Module modMain

    Dim BGW1 As New System.ComponentModel.BackgroundWorker

    Public Sub Main()

        BGW1.RunWorkerAsync()

    End Sub


'ERROR HERE
    Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BGW1.DoWork

    End Sub

End Module
*************************
billymcquearyAsked:
Who is Participating?
 
nouloukCommented:
Hi,
Try:
Dim WithEvents BGW1 As New System.ComponentModel.BackgroundWorker
0
 
billymcquearyAuthor Commented:
Wow, easiest 375 points ever.  Much thanks though, I'm off and running.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.