• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 885
  • Last Modified:

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
*************************
0
billymcqueary
Asked:
billymcqueary
1 Solution
 
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now