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 5 4659
"Stefan Filip" <St*********@discussions.microsoft.comwrote in message
news:E2**********************************@microsof t.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
Thanks for answering John, but I already did that. Here's how my code looks
like:
languageReady = false;
contestReady = false;
usercontrolsReady = false;
backendService.GetControlsConstantsCompleted += new
GetControlsConstantsCompletedEventHandler(backendS ervice_GetControlsConstantsCompleted);
backendService.GetControlsConstantsAsync(1);
backendService.GetContestIdByCodeCompleted += new
GetContestIdByCodeCompletedEventHandler(backendSer vice_GetContestIdByCodeCompleted);
backendService.GetContestIdByCodeAsync((string)Req uest.QueryString["contest"], 1);
backendService.GetLanguageIdByCodeCompleted += new
GetLanguageIdByCodeCompletedEventHandler(backendSe rvice_GetLanguageIdByCodeCompleted);
backendService.GetLanguageIdByCodeAsync((string)Re quest.QueryString["language"], 1);
((string)Request.QueryString["language"]);
while (!(languageReady && contestReady
&&usercontrolsReady))
{ }
Session["BackendContestData"] =
backendService.GetPublicContestData((int)Session["ContestId"]);
backendContestData =
(PublicContestData)(Session["BackendContestData"]);
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.
"Stefan Filip" <St*********@discussions.microsoft.comwrote in message
news:6C**********************************@microsof t.com...
Thanks for answering John, but I already did that. Here's how my code
looks
like:
languageReady = false;
contestReady = false;
usercontrolsReady = false;
backendService.GetControlsConstantsCompleted += new
GetControlsConstantsCompletedEventHandler(backendS ervice_GetControlsConstantsCompleted);
backendService.GetControlsConstantsAsync(1);
backendService.GetContestIdByCodeCompleted += new
GetContestIdByCodeCompletedEventHandler(backendSer vice_GetContestIdByCodeCompleted);
backendService.GetContestIdByCodeAsync((string)Req uest.QueryString["contest"],
1);
backendService.GetLanguageIdByCodeCompleted += new
GetLanguageIdByCodeCompletedEventHandler(backendSe rvice_GetLanguageIdByCodeCompleted);
backendService.GetLanguageIdByCodeAsync((string)Re quest.QueryString["language"],
1);
((string)Request.QueryString["language"]);
while (!(languageReady && contestReady
&&usercontrolsReady))
{ }
Session["BackendContestData"] =
backendService.GetPublicContestData((int)Session["ContestId"]);
backendContestData =
(PublicContestData)(Session["BackendContestData"]);
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
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*********@discussions.microsoft.comwrote in message
news:6C**********************************@microsof t.com...
Thanks for answering John, but I already did that. Here's how my code
looks
like:
languageReady = false;
contestReady = false;
usercontrolsReady = false;
backendService.GetControlsConstantsCompleted += new
GetControlsConstantsCompletedEventHandler(backendS ervice_GetControlsConstantsCompleted);
backendService.GetControlsConstantsAsync(1);
backendService.GetContestIdByCodeCompleted += new
GetContestIdByCodeCompletedEventHandler(backendSer vice_GetContestIdByCodeCompleted);
backendService.GetContestIdByCodeAsync((string)Req uest.QueryString["contest"],
1);
backendService.GetLanguageIdByCodeCompleted += new
GetLanguageIdByCodeCompletedEventHandler(backendSe rvice_GetLanguageIdByCodeCompleted);
backendService.GetLanguageIdByCodeAsync((string)Re quest.QueryString["language"],
1);
((string)Request.QueryString["language"]);
while (!(languageReady && contestReady
&&usercontrolsReady))
{ }
Session["BackendContestData"] =
backendService.GetPublicContestData((int)Session["ContestId"]);
backendContestData =
(PublicContestData)(Session["BackendContestData"]);
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
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.UseDefaultCredentials = true;
s.UnsafeAuthenticatedConnectionSharing = true;
ParameterizedThreadStart p = new ParameterizedThreadStart(Call);
Thread t = new Thread(p);
t.SetApartmentState(ApartmentState.STA);
t.Start(0);
Console.ReadLine();
}
static NLBService.NLBService s = new ConsoleApplication1.NLBService.NLBService();
static void Call(object o)
{
s.HelloWorldCompleted += new ConsoleApplication1.NLBService.HelloWorldCompleted EventHandler(s_HelloWorldCompleted);
s.HelloWorldAsync();
}
static void s_HelloWorldCompleted(object sender, ConsoleApplication1.NLBService.HelloWorldCompleted EventArgs e)
{
if (e.Error == null)
{
Console.WriteLine("ok");
}
else
{
Console.WriteLine("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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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...
|
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...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
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...
| |
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
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...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |