How to raise an event to do sth asynchronous in Web Service?

W

Wei Lu

Hi all,

I have a Web Service method to do some business by the invoker's input
param. The code is like this:

[WebMethod]
public string UpdateHotel(string hotelid) {
bool hotelstatus = GetHotelSta(hotelid);
if (hotelstatus)
{
return true;
}
else
{
//How to asynchronous do something here????
return false;
}
}

How can I do?

Wei Lu
 
S

Steven Cheng

Hi Wei,

From your description, you have a webservice method take an input parameter
and return some bool value depending on some server-side processing. And
you're wondering how to add some asynchronous processing in that webservice
method's function logic, correct?

According to the function prototype you provided,
========
public string UpdateHotel(string hotelid) {
bool hotelstatus = GetHotelSta(hotelid);
if (hotelstatus)
{
return true;
}
else
{
//How to asynchronous do something here????
return false;
}
}
=========

the method will only return a boolean value to the caller. Therefore, I'm
wondering what will you do in the "async operation" you want to inject? If
the operation will not affect the webservice itself(need to block it or
change its return value), I think you can simply start a new background
thread(create a new Thread or use ThreadPool thread) to do the work. Do you
think this will work for your scenario?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.



--------------------
From: "Wei Lu" <[email protected]>
Subject: How to raise an event to do sth asynchronous in Web Service?
Date: Wed, 8 Apr 2009 09:57:26 +0800
Hi all,

I have a Web Service method to do some business by the invoker's input
param. The code is like this:

[WebMethod]
public string UpdateHotel(string hotelid) {
bool hotelstatus = GetHotelSta(hotelid);
if (hotelstatus)
{
return true;
}
else
{
//How to asynchronous do something here????
return false;
}
}

How can I do?

Wei Lu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top