G
Guest
I have a simple windows application project. It has a form which has 2
buttons. The project has a web service reference. The web service has two web
methods Helloworld1 and Helloworld2 they both return "Hello world".
Helloworld1 has a 120 seconds delay.
One of the buttons on the form makes a async call to Helloworld1 web method
and the other button makes a sync call to Helloworld2. The problem is: if I
click on the button1 twice and try to click on the button 2. Application
hangs about 100 seconds and returns with a time out exception, in some cases
it returns the "Underlying connection is closed" exception.
Now I get the error if the web service is in a different machine then I'm
running the exe in. I tried this with both {win 2000 machine + IIS 5} and
{win 2003 server + IIS 6} with same result. If I 'm connecting to the local
web service, I don't get an error.
Is this a bug?
Here is Win app:
Imports System.Web.Services.Protocols
Public Class Form1
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 Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(40, 24)
Me.Button1.Name = "Button1"
Me.Button1.TabIndex = 0
Me.Button1.Text = "Async Call"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(40, 64)
Me.Button2.Name = "Button2"
Me.Button2.TabIndex = 1
Me.Button2.Text = "Sync Call"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(160, 126)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
AsyncTickler()
End Sub
Private wcrAsyncTicklerResult As WebClientAsyncResult
Dim objAsyncWebSvc1 As New localhost.Service1
Private Sub AsyncTickler()
Try
Application.DoEvents()
wcrAsyncTicklerResult =
objAsyncWebSvc1.BeginHelloWorld1(Nothing, Nothing)
Catch excGeneric As Exception
MessageBox.Show(excGeneric.ToString)
Finally
End Try
End Sub
Dim objSyncWebSvc1 As New localhost.Service1
Dim dtm As DateTime
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Try
dtm = Now
MessageBox.Show(objSyncWebSvc1.HelloWorld2())
Catch excGeneric As Exception
Dim lng As Long = Now.Ticks - dtm.Ticks
Dim dtm1 As New DateTime(lng)
MessageBox.Show("Response came back in " & dtm1.Minute & "mins
and " & dtm1.Second & " secs " & excGeneric.ToString)
Finally
End Try
End Sub
End Class
Here is Web Service:
Imports System.Web.Services
<System.Web.Services.WebService(Namespace :=
"http://tempuri.org/AsyncTesterWS/Service1")> _
Public Class Service1
Inherits System.Web.Services.WebService
#Region " Web Services Designer Generated Code "
Public Sub New()
MyBase.New()
'This call is required by the Web Services Designer.
InitializeComponent()
'Add your own initialization code after the InitializeComponent() call
End Sub
'Required by the Web Services Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Web Services Designer
'It can be modified using the Web Services Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
components = New System.ComponentModel.Container()
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
'CODEGEN: This procedure is required by the Web Services Designer
'Do not modify it using the code editor.
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
#End Region
' WEB SERVICE EXAMPLE
' The HelloWorld() example service returns the string Hello World.
' To build, uncomment the following lines then save and build the project.
' To test this web service, ensure that the .asmx file is the start page
' and press F5.
'
<WebMethod()> _
Public Function HelloWorld1() As String
System.Threading.Thread.Sleep(120000)
Return "Hello World"
End Function
<WebMethod()> _
Public Function HelloWorld2() As String
Return "Hello World"
End Function
End Class
buttons. The project has a web service reference. The web service has two web
methods Helloworld1 and Helloworld2 they both return "Hello world".
Helloworld1 has a 120 seconds delay.
One of the buttons on the form makes a async call to Helloworld1 web method
and the other button makes a sync call to Helloworld2. The problem is: if I
click on the button1 twice and try to click on the button 2. Application
hangs about 100 seconds and returns with a time out exception, in some cases
it returns the "Underlying connection is closed" exception.
Now I get the error if the web service is in a different machine then I'm
running the exe in. I tried this with both {win 2000 machine + IIS 5} and
{win 2003 server + IIS 6} with same result. If I 'm connecting to the local
web service, I don't get an error.
Is this a bug?
Here is Win app:
Imports System.Web.Services.Protocols
Public Class Form1
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 Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(40, 24)
Me.Button1.Name = "Button1"
Me.Button1.TabIndex = 0
Me.Button1.Text = "Async Call"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(40, 64)
Me.Button2.Name = "Button2"
Me.Button2.TabIndex = 1
Me.Button2.Text = "Sync Call"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(160, 126)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
AsyncTickler()
End Sub
Private wcrAsyncTicklerResult As WebClientAsyncResult
Dim objAsyncWebSvc1 As New localhost.Service1
Private Sub AsyncTickler()
Try
Application.DoEvents()
wcrAsyncTicklerResult =
objAsyncWebSvc1.BeginHelloWorld1(Nothing, Nothing)
Catch excGeneric As Exception
MessageBox.Show(excGeneric.ToString)
Finally
End Try
End Sub
Dim objSyncWebSvc1 As New localhost.Service1
Dim dtm As DateTime
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Try
dtm = Now
MessageBox.Show(objSyncWebSvc1.HelloWorld2())
Catch excGeneric As Exception
Dim lng As Long = Now.Ticks - dtm.Ticks
Dim dtm1 As New DateTime(lng)
MessageBox.Show("Response came back in " & dtm1.Minute & "mins
and " & dtm1.Second & " secs " & excGeneric.ToString)
Finally
End Try
End Sub
End Class
Here is Web Service:
Imports System.Web.Services
<System.Web.Services.WebService(Namespace :=
"http://tempuri.org/AsyncTesterWS/Service1")> _
Public Class Service1
Inherits System.Web.Services.WebService
#Region " Web Services Designer Generated Code "
Public Sub New()
MyBase.New()
'This call is required by the Web Services Designer.
InitializeComponent()
'Add your own initialization code after the InitializeComponent() call
End Sub
'Required by the Web Services Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Web Services Designer
'It can be modified using the Web Services Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
components = New System.ComponentModel.Container()
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
'CODEGEN: This procedure is required by the Web Services Designer
'Do not modify it using the code editor.
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
#End Region
' WEB SERVICE EXAMPLE
' The HelloWorld() example service returns the string Hello World.
' To build, uncomment the following lines then save and build the project.
' To test this web service, ensure that the .asmx file is the start page
' and press F5.
'
<WebMethod()> _
Public Function HelloWorld1() As String
System.Threading.Thread.Sleep(120000)
Return "Hello World"
End Function
<WebMethod()> _
Public Function HelloWorld2() As String
Return "Hello World"
End Function
End Class