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

Discussion in 'ASP .Net Web Services' started by Wei Lu, Apr 8, 2009.

  1. Wei  Lu

    Wei Lu Guest

    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
    Wei Lu, Apr 8, 2009
    #1
    1. Advertising

  2. Wei  Lu

    Steven Cheng Guest

    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:
    .

    ==================================================
    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" <>
    >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
    >
    >
    Steven Cheng, Apr 8, 2009
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jacol

    raise or not to raise [Newbie]

    Jacol, Feb 3, 2007, in forum: Python
    Replies:
    5
    Views:
    406
    Gabriel Genellina
    Feb 5, 2007
  2. ernest
    Replies:
    2
    Views:
    289
    Roy Smith
    Nov 14, 2010
  3. Jack Bates
    Replies:
    0
    Views:
    277
    Jack Bates
    May 2, 2011
  4. bvdp

    Raise X or Raise X()?

    bvdp, Mar 11, 2012, in forum: Python
    Replies:
    10
    Views:
    367
    Stefan Behnel
    Mar 12, 2012
  5. elodie

    $sth->errstr; and $sth->execute;

    elodie, Nov 7, 2011, in forum: Perl Misc
    Replies:
    0
    Views:
    207
    elodie
    Nov 7, 2011
Loading...

Share This Page