I am creating an application in VB.NET where users are able to attach XML via an OpenFileDialog and fire it at the Web Service.
I wish to have a progress bar at the bottom as at the moment, the GUI hangs and users think it has crashed while it is waiting for a response.
My code is below:
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
If hubURLtxtbx.Text = "LIVE" Then
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
System.Threading.Thread.Sleep(1000) ' Sleep for 1 Second
' Report The progress of the Background Worker.
BackgroundWorker1.ReportProgress(CInt((i / GlobalVariables.m_CountTo) * 100))
Private Sub BackgroundWorker1_ProgressChanged(ByVal sender As Object, _
ByVal e As System.ComponentModel.ProgressChangedEventArgs) _
If GlobalVariables.response = "" Then
ProgBar.Value = e.ProgressPercentage
ProgBar.Value = 100
Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object, _
ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) _
If e.Cancelled Then
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.
Basically at the moment with the code as above the progress bar is updating AFTER I have received the XML response from the web service.
I want to have it so that the call is made and when the call is made the progress is updating, then when the call is successfully the bar is completely full?
Can anyone shed any light on this for me at all please?
On debug it appears the 'hanging' is when the XStreamUAT/XStreamLIVE Sub is called and it uses the Web Service Reference Client Object to send the XML to the Service.