Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WPF后台工作进程无法识别工作进程对象_Wpf_Vb.net_Backgroundworker - Fatal编程技术网

WPF后台工作进程无法识别工作进程对象

WPF后台工作进程无法识别工作进程对象,wpf,vb.net,backgroundworker,Wpf,Vb.net,Backgroundworker,我有以下代码将后台工作程序添加到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 Sy

我有以下代码将后台工作程序添加到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 worker事件,我得到以下错误:

Handles子句需要在包含类型或其基类型之一中定义的WithEvents变量

似乎在事件声明中缺少了一些内容,但找不到


有什么想法吗?

在声明新的backgroundworker时尝试添加“WithEvents”。以下是Windows窗体设计器生成的代码中我的backgroundworker对象之一的代码片段:

Friend WithEvents bWorker As System.ComponentModel.BackgroundWorker
让我知道这是否有帮助

尝试更换

Dim worker As New BackgroundWorker


你的DoWork活动的签名看起来很时髦-不应该是Object,DoWorkEventArgs吗


您有Object,BackgroundWorker

我现在遇到另一个错误:>方法无法处理事件的公共事件DoWork,因为它们没有兼容的签名。有什么想法吗?那确实管用。谢谢。我将查看代码的其余部分现在是否有响应。谢谢
Private WithEvents worker As New BackgroundWorker