我有以下代码将后台工作人员添加到 VB.net WPF 项目中:
Imports System
Imports System.ComponentModel
Imports System.ComponentModel.BackgroundWorker
Imports System.IO
Imports System.Threading
Imports System.Net
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Media
Imports System.Windows.Media.Animation
Imports System.Windows.Navigation
Imports System.ServiceProcess
Partial Public Class Window1
Public Sub New()
MyBase.New()
Me.InitializeComponent()
End Sub
End Class
Public Class Window1
Dim worker As New BackgroundWorker
Private Sub worker_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.BackgroundWorker) Handles worker.DoWork
End Sub
End Class
对于 DoWork 工作人员事件,我收到以下错误:
Handles 子句需要在包含类型或其基类型之一中定义的 WithEvents 变量。
似乎它在事件声明中丢失了一些东西,但找不到它。
有任何想法吗?