Unexpected Async Web Service behaviour

Discussion in 'ASP .Net Web Services' started by Ross Porter, Dec 23, 2003.

  1. Ross Porter

    Ross Porter Guest

    I am calling a web service asyncronously and polling the
    IAsync result variable to determine if processing is
    complete(using IsCompleted),nif not completed, I am
    writing a message to the console ("still processing...").
    The problem seems to be that the IAsync result variable's
    IsCompleted property never retruns true so the loop is
    infinite.

    Heres the code in vb: BTW -- the syncronous call is
    working fine.

    Sub Main()
    Console.WriteLine("--------Begin Sync Call--------
    ----")
    callsync()
    Console.WriteLine("--------Begin Asyc Call--------
    ----")
    callasync()
    End Sub

    Sub callsync()
    Dim wR As New Web.WoodgroveOnlineBank
    Dim aI As Web.Acct
    aI = wR.GetAccount(1)
    WriteValues(aI)
    End Sub

    Sub callasync()
    Dim wR As New Web.WoodgroveOnlineBank
    Dim cbObj As New AsyncCallback(AddressOf
    CallBackMethod)
    Dim IAR As IAsyncResult = wR.BeginGetAccount(1,
    cbObj, wR)
    Do Until IAR.IsCompleted
    Console.WriteLine("Still processing . . .")
    Thread.Sleep(1000)
    Loop

    End Sub

    Sub CallBackMethod(ByVal ar As IAsyncResult)
    Dim wR As Web.WoodgroveOnlineBank = ar.AsyncState
    Dim act As Web.Acct
    act = wR.EndGetAccount(ar)
    WriteValues(act)
    End Sub
    Sub WriteValues(ByVal aI As Web.Acct)
    Console.WriteLine("Account {0} - {2} has a
    balance of {1}", _
    aI.accountID, _
    aI.balance, _
    aI.description)
    Console.Read()
    End Sub
     
    Ross Porter, Dec 23, 2003
    #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. Lucas Tam

    Async Web Service - Maximum Time?

    Lucas Tam, Apr 13, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    453
    Lucas Tam
    Apr 14, 2005
  2. Replies:
    0
    Views:
    689
  3. Emre Aydinceren

    Async web service problem

    Emre Aydinceren, Jul 22, 2003, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    132
    Emre Aydinceren
    Jul 22, 2003
  4. VR

    ending an async call to a web service

    VR, Sep 11, 2003, in forum: ASP .Net Web Services
    Replies:
    2
    Views:
    206
  5. Steven
    Replies:
    0
    Views:
    395
    Steven
    Nov 30, 2005
Loading...

Share This Page