Calling Async object within a webservice method

Discussion in 'ASP .Net' started by Paul Hadfield, Sep 17, 2007.

  1. Hi,

    From reading various articles on scalability issues, I understand that there
    is only a finite number of ASP.NET worker threads and any long running task
    within ASP.NET should be fired off on a seperate thread using an async call.
    All the articles I can find are either on implementing an async webpage, or
    calling an async webservice. I can not however find any article on how to
    make calls within a webservice asynchronous. Consider the following:

    [WebMethod]
    public int LongRunningTask(int inputValue)
    {
    BusinessObject bo = new BusinessObject();
    return bo.Process(inputValue); // This typically takes 1-10 seconds,
    but could take up to one minute!
    }

    Now "BusinessObject" implements the Microsoft "Asynchronous Design Pattern",
    having "BeginProcess()" and "EndProcess()" methods, implementing callback,
    IAsyncResult and state. But how do you call this in the web method? Is
    there any way to hide the fact from the webservice consumer that the call to
    the business object is asynchronous? Unlike Page, the base class WebService
    doesn't appear to expose any ability to register call backs for any sort of
    async call.

    My gut feel is that the above is not possible, therefore I have to make the
    webservice webmethod asynchronous (i.e. have webmethods
    "BeginLongRunningTask" and "EndLongRunningTask"). How do I implement this,
    hiding the non-async LongRunningTask() webmethod, as I won't want anyone to
    consume that webmethod.

    Regards,

    - Paul.
     
    Paul Hadfield, Sep 17, 2007
    #1
    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. Michael
    Replies:
    3
    Views:
    173
    Dave Purrington
    Dec 23, 2003
  2. Michael
    Replies:
    2
    Views:
    192
    Michael
    Dec 19, 2003
  3. Steven
    Replies:
    0
    Views:
    395
    Steven
    Nov 30, 2005
  4. heinrich.elsigan
    Replies:
    2
    Views:
    184
    Willy Van den Driessche
    May 21, 2006
  5. René Preußler

    Asynchronous Call of WebService method within a WebService

    René Preußler, Oct 29, 2008, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    208
    René Preußler
    Oct 29, 2008
Loading...

Share This Page