asked on
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
BackgroundWorker1.RunWorkerAsync()
If hubURLtxtbx.Text = "LIVE" Then
XStreamLive()
Else
XStreamUAT()
End If
End Sub
Private Sub My_BgWorker_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
For i As Integer = 0 To GlobalVariables.m_CountTo
' Has the background worker be told to stop?
If BackgroundWorker1.CancellationPending Then
' Set Cancel to True
e.Cancel = True
Exit For
End If
System.Threading.Thread.Sleep(1000) ' Sleep for 1 Second
' Report The progress of the Background Worker.
BackgroundWorker1.ReportProgress(CInt((i / GlobalVariables.m_CountTo) * 100))
Next
End Sub
Private Sub BackgroundWorker1_ProgressChanged(ByVal sender As Object, _
ByVal e As System.ComponentModel.ProgressChangedEventArgs) _
Handles BackgroundWorker1.ProgressChanged
If GlobalVariables.response = "" Then
ProgBar.Value = e.ProgressPercentage
Else
ProgBar.Value = 100
End If
End Sub
Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object, _
ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) _
Handles BackgroundWorker1.RunWorkerCompleted
If e.Cancelled Then
MsgBox("Cancelled")
Else
MsgBox("Completed")
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
' Is the Background Worker do some work?
If BackgroundWorker1.IsBusy Then
'If it supports cancellation, Cancel It
If BackgroundWorker1.WorkerSupportsCancellation Then
' Tell the Background Worker to stop working.
BackgroundWorker1.CancelAsync()
End If
End If
End Sub
ASKER
The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.
TRUSTED BY
ASKER
Open in new window
I have moved the IF Statement instead the BackGroundWOrker DoWork Event however it STILL only moves the progress bar after the XML has fired and been returned.
I want it to fire and the progress go up while it is waiting for a return.
Cheers,
James