473,606 Members | 2,444 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Async web service methods calls

Hello,

I'm trying to launch several async calls for different methods of a web
service, but I get this error when i'm trying to read the result (There was
an error during asynchronous processing. Unique state object is required for
multiple asynchronous simultaneous operations to be outstanding.). I read the
post at
http://forums.microsoft.com/MSDN/Sho...79895&SiteID=1, and I
get the same error, but I have async calls to different web service methods.
What should I do?
Thanks
Oct 17 '07 #1
5 4673
"Stefan Filip" <St*********@di scussions.micro soft.comwrote in message
news:E2******** *************** ***********@mic rosoft.com...
Hello,

I'm trying to launch several async calls for different methods of a web
service, but I get this error when i'm trying to read the result (There
was
an error during asynchronous processing. Unique state object is required
for
multiple asynchronous simultaneous operations to be outstanding.). I read
the
post at
http://forums.microsoft.com/MSDN/Sho...79895&SiteID=1,
and I
get the same error, but I have async calls to different web service
methods.
What should I do?
You should use a unique state object. It's not a per-method. Thing.

--
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer
Oct 17 '07 #2
Thanks for answering John, but I already did that. Here's how my code looks
like:

languageReady = false;
contestReady = false;
usercontrolsRea dy = false;

backendService. GetControlsCons tantsCompleted += new
GetControlsCons tantsCompletedE ventHandler(bac kendService_Get ControlsConstan tsCompleted);
backendService. GetControlsCons tantsAsync(1);
backendService. GetContestIdByC odeCompleted += new
GetContestIdByC odeCompletedEve ntHandler(backe ndService_GetCo ntestIdByCodeCo mpleted);

backendService. GetContestIdByC odeAsync((strin g)Request.Query String["contest"], 1);
backendService. GetLanguageIdBy CodeCompleted += new
GetLanguageIdBy CodeCompletedEv entHandler(back endService_GetL anguageIdByCode Completed);

backendService. GetLanguageIdBy CodeAsync((stri ng)Request.Quer yString["language"], 1);

((string)Reques t.QueryString["language"]);

while (!(languageRead y && contestReady
&&usercontrolsR eady))
{ }
Session["BackendContest Data"] =
backendService. GetPublicContes tData((int)Sess ion["ContestId"]);
backendContestD ata =
(PublicContestD ata)(Session["BackendContest Data"]);

So I have 3 web services methods which are called async, and I want to wait
until I get the response from all the 3 of them (I set the bool values to
true in the event handler for the completion of the web service methods). As
you can see all 3 methods are called with the same unique user state (1) and
if I do this I get the error inside the event handlers. If I set each method
a different unique user state (1, 2, 3 for example) then my events are not
fired.
Oct 18 '07 #3
"Stefan Filip" <St*********@di scussions.micro soft.comwrote in message
news:6C******** *************** ***********@mic rosoft.com...
Thanks for answering John, but I already did that. Here's how my code
looks
like:

languageReady = false;
contestReady = false;
usercontrolsRea dy = false;

backendService. GetControlsCons tantsCompleted += new
GetControlsCons tantsCompletedE ventHandler(bac kendService_Get ControlsConstan tsCompleted);
backendService. GetControlsCons tantsAsync(1);
backendService. GetContestIdByC odeCompleted += new
GetContestIdByC odeCompletedEve ntHandler(backe ndService_GetCo ntestIdByCodeCo mpleted);

backendService. GetContestIdByC odeAsync((strin g)Request.Query String["contest"],
1);
backendService. GetLanguageIdBy CodeCompleted += new
GetLanguageIdBy CodeCompletedEv entHandler(back endService_GetL anguageIdByCode Completed);

backendService. GetLanguageIdBy CodeAsync((stri ng)Request.Quer yString["language"],
1);

((string)Reques t.QueryString["language"]);

while (!(languageRead y && contestReady
&&usercontrolsR eady))
{ }
Session["BackendContest Data"] =
backendService. GetPublicContes tData((int)Sess ion["ContestId"]);
backendContestD ata =
(PublicContestD ata)(Session["BackendContest Data"]);

So I have 3 web services methods which are called async, and I want to
wait
until I get the response from all the 3 of them (I set the bool values to
true in the event handler for the completion of the web service methods).
As
you can see all 3 methods are called with the same unique user state (1)
and
if I do this I get the error inside the event handlers. If I set each
method
a different unique user state (1, 2, 3 for example) then my events are not
fired.
Sorry for not following up sooner, but aren't you the poster who got an
error complaining that you can't use the same state in multiple calls? Yet
here, you're telling me that you use the same state, and you get an error.
What did I miss?

What happens if you try something like:

object state1 = 1;
object state2 = 1;
object state3 = 1;

and pass state1, etc. as the state?

Perhaps you're not really passing the number 1? Are you passing some other
value type?
--
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer
Oct 23 '07 #4
Hi,

I finally realised what was going on. The problem was that the events were
not invoked because I was in an infinite loop (the while) and I didn't
realise that I was on the same thread, so the events could not be invoked.
Thanks anyway for your replies and sorry for loosing your time with this :).

"John Saunders [MVP]" wrote:
"Stefan Filip" <St*********@di scussions.micro soft.comwrote in message
news:6C******** *************** ***********@mic rosoft.com...
Thanks for answering John, but I already did that. Here's how my code
looks
like:

languageReady = false;
contestReady = false;
usercontrolsRea dy = false;

backendService. GetControlsCons tantsCompleted += new
GetControlsCons tantsCompletedE ventHandler(bac kendService_Get ControlsConstan tsCompleted);
backendService. GetControlsCons tantsAsync(1);
backendService. GetContestIdByC odeCompleted += new
GetContestIdByC odeCompletedEve ntHandler(backe ndService_GetCo ntestIdByCodeCo mpleted);

backendService. GetContestIdByC odeAsync((strin g)Request.Query String["contest"],
1);
backendService. GetLanguageIdBy CodeCompleted += new
GetLanguageIdBy CodeCompletedEv entHandler(back endService_GetL anguageIdByCode Completed);

backendService. GetLanguageIdBy CodeAsync((stri ng)Request.Quer yString["language"],
1);

((string)Reques t.QueryString["language"]);

while (!(languageRead y && contestReady
&&usercontrolsR eady))
{ }
Session["BackendContest Data"] =
backendService. GetPublicContes tData((int)Sess ion["ContestId"]);
backendContestD ata =
(PublicContestD ata)(Session["BackendContest Data"]);

So I have 3 web services methods which are called async, and I want to
wait
until I get the response from all the 3 of them (I set the bool values to
true in the event handler for the completion of the web service methods).
As
you can see all 3 methods are called with the same unique user state (1)
and
if I do this I get the error inside the event handlers. If I set each
method
a different unique user state (1, 2, 3 for example) then my events are not
fired.

Sorry for not following up sooner, but aren't you the poster who got an
error complaining that you can't use the same state in multiple calls? Yet
here, you're telling me that you use the same state, and you get an error.
What did I miss?

What happens if you try something like:

object state1 = 1;
object state2 = 1;
object state3 = 1;

and pass state1, etc. as the state?

Perhaps you're not really passing the number 1? Are you passing some other
value type?
--
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer
Oct 23 '07 #5
Hello,

I'm trying to launch several async calls for different methods of a web
service, but I get this error when i'm trying to read the result (There was
an error during asynchronous processing. Unique state object is required for
multiple asynchronous simultaneous operations to be outstanding.). I read the
post at
http://forums.microsoft.com/MSDN/Sho...79895&SiteID=1, and I
get the same error, but I have async calls to different web service methods.
What should I do?
Thanks
class Program
{
static void Main(string[] args)
{
s.UseDefaultCre dentials = true;
s.UnsafeAuthent icatedConnectio nSharing = true;

ParameterizedTh readStart p = new ParameterizedTh readStart(Call) ;
Thread t = new Thread(p);
t.SetApartmentS tate(ApartmentS tate.STA);
t.Start(0);

Console.ReadLin e();
}

static NLBService.NLBS ervice s = new ConsoleApplicat ion1.NLBService .NLBService();

static void Call(object o)
{
s.HelloWorldCom pleted += new ConsoleApplicat ion1.NLBService .HelloWorldComp letedEventHandl er(s_HelloWorld Completed);
s.HelloWorldAsy nc();
}

static void s_HelloWorldCom pleted(object sender, ConsoleApplicat ion1.NLBService .HelloWorldComp letedEventArgs e)
{
if (e.Error == null)
{
Console.WriteLi ne("ok");
}
else
{
Console.WriteLi ne("error");
}
}
}

Why does not this work?
If I want to use it synchronous it works fine, but I can not figure out, how to call a web service asynchronous from a thread that is different from the working thread.

Thank You

BizTalk Utilities - Frustration free BizTalk Adapters
http://www.topxml.com/biztalkutilities
Dec 17 '07 #6

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

Similar topics

1
4315
by: Simon Hart | last post by:
Hi, I thought I'd just open a thread in an attempt to get peoples feelers with regards to multithreading vs Async Web Service processing. Of course Web Services makes it easy to do Async method calling, but what if you are already in a worker thread in a Windows Forms application when doing the web service call. In this case there is no need to use Async Begin..End features that .NET kindly presents us with.
0
1462
by: Idriss | last post by:
I am using VS2005 and WSE 2.0. I am using the new async web methods calls i.e proxy.MethodAsync and proxy.MethodCompleted event handler My question is if I have several methods in the web service, is there an example to direct all async calls to the same event handler. thanks Idriss
10
2626
by: Brian Parker | last post by:
I inherited a C++ DLL that I need to remotely call multiple times asynchronously. What I have developed is: CSharp web application that makes asynchronous calls to a CSharp Web Service. The Web Service calls the DLL, which does some heavy processing, then sends the results back to the CSharp web application. The problem is that the calls to the DLL in the Web Service are blocking each other. If I send 10 async requests to the Web...
6
3811
by: Shak | last post by:
Hi all, Three questions really: 1) The async call to the networkstream's endread() (or even endxxx() in general) blocks. Async calls are made on the threadpool - aren't we advised not to cause these to block? 2) You can connect together a binaryreader to a networkstream:
7
2849
by: Shak | last post by:
Hi all, I'm trying to write a thread-safe async method to send a message of the form (type)(contents). My model is as follows: private void SendMessage(int type, string message) { //lets send the messagetype via async NetworkStream ns = client.GetStream(); //assume client globally accessible
11
8589
by: atlaste | last post by:
Hi, In an attempt to create a full-blown webcrawler I've found myself writing a wrapper around the Socket class in an attempt to make it completely async, supporting timeouts and some scheduling mechanisms. I use a non-blocking approach for this, using the call to 'poll' to support the async mechanism - rather than the 'begin' and 'end' functions. I already found that connecting doesn't set the "isconnected" variable correctly...
0
1836
by: =?Utf-8?B?RGF2ZQ==?= | last post by:
Hi, I'm trying to implement asynch web service calls in .NET 2.0 However, when I created a ClassLibrary project, the WebReference I added doesn't include the Begin/End methods (as in 1.1) but have been replaced by <methodname>Asynch and <methodname>Completed events. I got it to work by wiring up the completed event but I have a couple questions. 1.) To test the Class library, I instantiated it from a windows form but
2
5558
by: jojoba | last post by:
Hello to all! I have a fairly simple webservice running in asp.net ajax under c# (vs 2008). I built the service and it runs just dandy when i test it by itself in visual studio. However, to make it work, i had to break up the webmethod into the BeginXXX, EndXXX model as per http://msdn2.microsoft.com/en-us/library/aa480516.aspx But now, i can no longer call this method from javascript (since to
1
1964
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... There are a few questions wrapped up in this, but the main one is that the WebService.MyMethodAsync() methods that are automatically generated in the client code by VS 2005 don't seem to be finishing for me. We have a VS add-in written in .net that used to make a number of database calls to fill forms. To improve security, we moved the db calls to a web service and return DataSets for the calls (the result sets are always...
0
8024
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7959
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8449
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8432
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8105
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8310
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5968
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3942
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.