Asynchronus WebService call Progress Bar
I'm fairly new to asynchronus calls and was wondering if this is possible before I dive in looking. Thanx! :)
I'm fairly new to asynchronus calls and was wondering if this is possible before I dive in looking. Thanx! :)
Check out this article: <a href=" http://msdn.microsoft.com/library/en-us/dnservice/html/service09032002.asp"></a>
Will that help you get started?
Check out this article: <a href="http://msdn.microsoft.com/library/en-us/dnservice/html/service09032002.asp">Asynchronous Web Service Calls over HTTP with the .NET Framework</a>
Will that help you get started?
So, I would actually recommend taking this idea and asking over in the ASP.Net Forums. I have already posted a message about this here: <a href="http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=179538">ASP.Net Forums - Post 179538</a>.
Here's a lame-o example of doing this. Really, all users need is indication of progress, for the most part. Although you might be able to work out some sort of regularly-timed callback from the service, is that really worth it?
Public Class Form2
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents tmrProgress As System.Windows.Forms.Timer
Friend WithEvents ProgressBar1 As System.Windows.Forms.ProgressBar
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents tmrService As System.Windows.Forms.Timer
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Me.tmrProgress = New System.Windows.Forms.Timer(Me.components)
Me.ProgressBar1 = New System.Windows.Forms.ProgressBar()
Me.Button1 = New System.Windows.Forms.Button()
Me.tmrService = New System.Windows.Forms.Timer(Me.components)
Me.SuspendLayout()
'
'tmrProgress
'
Me.tmrProgress.Interval = 50
'
'ProgressBar1
'
Me.ProgressBar1.Location = New System.Drawing.Point(16, 64)
Me.ProgressBar1.Name = "ProgressBar1"
Me.ProgressBar1.Size = New System.Drawing.Size(296, 23)
Me.ProgressBar1.TabIndex = 0
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(16, 16)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(168, 40)
Me.Button1.TabIndex = 1
Me.Button1.Text = "Run Web Service"
'
'tmrService
'
'
'Form2
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(320, 101)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button1, Me.ProgressBar1})
Me.Name = "Form2"
Me.Text = "Form2"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub tmrProgress_Tick( _
ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles tmrProgress.Tick
UpdateProgress(ProgressBar1)
End Sub
Private Sub UpdateProgress(ByVal pb As ProgressBar)
pb.Value = (pb.Value + 1) Mod pb.Maximum
End Sub
Private Sub ClearProgress(ByVal pb As ProgressBar)
tmrProgress.Enabled = False
pb.Value = pb.Minimum
End Sub
Private Sub Button1_Click( _
ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles Button1.Click
tmrProgress.Enabled = True
' Emulate a long-running process. Fake a
' service that runs for 10 seconds.
tmrService.Interval = 10000
tmrService.Enabled = True
End Sub
Private Sub tmrService_Tick( _
ByVal sender As Object, ByVal e As System.EventArgs) _
Handles tmrService.Tick
ClearProgress(ProgressBar1)
End Sub
End Class
The question is: How do you safely cancel the asynch web method?