使用backgroundworker时强制转换无效

时间:2019-02-05 10:32:07

标签: vb.net multithreading backgroundworker

我已将代码从Form_Load移至BackgroundWorker,但显示“指定的转换无效”,在此处上传:My Codes Image

    Private Sub FirstRunWorker_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles FirstRunWorker.DoWork
    Dim url1 As String = publicurl & "index.php"
    Dim datavillages1 As String = TGet("", url1, url1, My.Settings.useragent)
    If datavillages1.Contains("error") Then
        'ADD LOG
    Else
        wb.DocumentText = datavillages1
        While wb.ReadyState <> WebBrowserReadyState.Complete
            Application.DoEvents()
        End While
    End If
End Sub

主要是它的工作,但不是后台工作人员,谢谢您的帮助

1 个答案:

答案 0 :(得分:0)

感谢您的帮助和解答,我通过invoke解决了我的问题! 现在我可以访问任何控件和功能

    Me.Invoke(New MethodInvoker(Function()
'dosomething
                                        End Function))