473,499 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Blocking problem/bug with enableSession=true and asynchronous web service calls?

Hi,

I've found what appears to be a bug with ASP.NET web service method
invocation - making it impossible to invoke and get the result of a
synchronous web call after an asynchronous call has been made if both are
using sessions.

Heres an example for two calls in the web service, the first is expected to
be executed asynchronously by the client and the second to get the progress
of the first while it is executing:

[SoapRpcMethod(RequestNamespace="",ResponseNamespac e="")]
[WebMethod(EnableSession = true, Description="")]
public MyResult DoLongTask(string progressHandle)
{
try
{
Thread.Sleep(7000);
return new MyResult();
} catch (Exception ex) { return null; }
}

static int count=0;
[SoapRpcMethod( RequestNamespace="",ResponseNamespace="")]
[WebMethod (EnableSession = true, Description="")]
public ProgressEvent GetProgress(string progressHandle)
{
try
{
Debug.WriteLine(DateTime.Now.ToLongTimeString()+ " Trying to get
progress for "+progressHandle);
ProgressEvent pe = new ProgressEvent(count+=10);
if (count==100) count=0;
return pe;
} catch (Exception ex) { return null;}
}

I stripped the calls down to almost nothing, removing the progress updating
and sharing to try and isolate the cause of a strange problem in the client:

e.g.
MyService ap = new MyService();
ap.CookieContainer = new CookieContainer();
ap.Login("blah");
string handle = Guid.NewGuid().ToString("N");
System.Diagnostics.Debug.WriteLine(DateTime.Now.To LongTimeString()+" FORM1:
About to do long task");
ap.BeginDoLongTask(handle);
System.Diagnostics.Debug.WriteLine(DateTime.Now.To LongTimeString()+" FORM1:
Back from do long task begin call");
ProgressEvent e = null;
bool done = false;
while (!done)
{
try
{
System.Diagnostics.Debug.WriteLine(DateTime.Now.To LongTimeString()+"
FORM1: Getting progress");
e = ap.GetProgress(handle);
System.Diagnostics.Debug.WriteLine(DateTime.Now.To LongTimeString()+"
FORM1: Got progress");
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
if (e!=null) {
Debug.WriteLine(e.percentComplete);
if (e.percentComplete==100) done = true;
}
Application.DoEvents();
}
}

What you'd expect is that the async call will return immediately and then
for the GetProgress calls to quickly count to 100. That isn't what happens.

The BeginDoLongTask call does complete immediately but there is a 7 second
gap between the time printed by "FORM1: About to do long task" and the
return value from that - which should be almost instant. That gap is EXACTLY
the same as the sleep and you can play with that figure to see it's the
same. Further, the very first writeline in the GetProgress call on the
server ("Trying to get progress for ") DOES NOT EXECUTE until the
*asynchronous* call on the server has finished. Once the first "blocked"
GetProgress call succeeds the remaining GetProgress calls work as expected.

This is all really messed up.

However, the "cure" (or at least workaround) after two confused days is to
take "enableSession=true" out of either of the GetProgress or DoLongTask
methods (or make the DoLongTask OneWay=true). Then you get the expected
behavior: the GetProgress calls quickly count to 100 regardless of what is
happening (what sleep) in the DoLongTask call.

So whats going on here? Am I doing something really wrong? Why should the
"enableSession" flag cause this incorrect behaviour? And how can I actually
use the session in both methods?

Jonathan
Nov 18 '05 #1
0 1645

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3095
by: Steven Farlie | last post by:
I am attempting to write to a named pipe using fwrite(). Unfortunately fwrite() will block until the pipe is read by an external program. This call does not have a timeout parameter and I have not...
3
3671
by: Robert A. van Ginkel | last post by:
In news:OZ0W9RsdDHA.2432@TK2MSFTNGP10.phx.gbl... I ask the question how I can see if all the data is on the other side of the connection. I got as answer that I should use the blocking property. I...
1
2339
by: Sonya | last post by:
Hello, I have trouble connecting to Access database from my web service. Database is located in a subdirectory of where service pages are. Code below produces the following exception: "No error...
0
1294
by: DotNetShadow | last post by:
Hi Guys I came across this article which deals with Performance Considerations for Making Web Service Calls from ASPX Pages:...
3
15871
by: Grigs | last post by:
Hello, I have created Windows Services before using C# and have had no problems. Not to mention, the one I currently am having problems with worked great for the first 3 days. Then I added some...
1
1478
by: Kevin Yu | last post by:
Hi all in .NET 2.0, the enableSession attribute will not be there. so if I have it in .NET 1.1, will it still work in .NET 2.0? Kevin
1
1196
by: JMMB | last post by:
The following code works fine when testing with the help web page, but it doesn't work when running from the client application. Anybody knows what could be the problem here? thanks a lot. JMMB ...
4
3233
by: =?Utf-8?B?TmFkYXYgUG9wcGxld2VsbA==?= | last post by:
Hi everybody, I've got two questions about using the EnableSession property with an ASP.NET WebService: First Question: I'm trying to create a web service with EnableSession=true. I can't...
6
6983
by: Pat B | last post by:
Hi, I'm writing my own implementation of the Gnutella P2P protocol using C#. I have implemented it using BeginReceive and EndReceive calls so as not to block when waiting for data from the...
0
7134
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7012
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7180
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7225
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6901
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7392
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4920
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
307
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.