Cant seem to figure out what Im doing wrong here, I get a type expected error from vb when I try to compile from the first backgroundWorker part of this (it automatically makes it a lowercase "b" could that have something to do with this?)
entire codeCode:Dim worker As backgroundWorker = DirectCast(sender, backgroundWorker)
Thanks in advance for any help!Code:Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Raise the DoWork event in a worker thread. Me.BackgroundWorker1.RunWorkerAsync() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.BackgroundWorker1.RunWorkerAsync(CInt(Me.NumericUpDown1.Value)) End Sub 'This method is executed in a worker thread. Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, _ ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork Dim worker As backgroundWorker = DirectCast(sender, backgroundWorker) Dim iterationCount As Integer = 0 If TypeOf e.Argument Is Integer Then iterationCount = CInt(e.Argument) End If For i As Integer = 1 To iterationCount Step 1 'Do something here. Next i End Sub 'This method is executed in the UI thread. Private Sub BackgroundWorker1_ProgressChanged(ByVal sender As Object, _ ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged Me.ProgressBar1.Value = e.ProgressPercentage Me.Label1.Text = TryCast(e.UserState, String) End Sub 'This method is executed in the UI thread. Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object, _ ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted Me.Label1.Text = "Operation complete" End Sub End Class




Reply With Quote