WebService and timeout

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • shark

    WebService and timeout

    Hi.

    I'm dealing with scenario when call to any web method ends up with timeout
    and I try to add the user a chance to retry (wait a little bit)
    My service proxy code looks like this:

    AsyncCallback cb = new AsyncCallback(S erviceCallback) ;
    IAsyncResult result1 = BeginInvoke(met hodName, parameters, cb, this);
    if(result1.IsCo mpleted == false)
    {
    while(true)
    {
    bTO = result1.AsyncWa itHandle.WaitOn e(Timeout, true);
    if(bTO == false)//time out occured
    {
    //display window and ask the user to wait a moment, user press
    OK when it sure that web method finished
    }
    if(result1.IsCo mpleted)
    break;
    }
    object[] ret = EndInvoke(resul t1);// error every time when time out
    occured (bTO = false)
    }
    My scenario is following:
    1. BeginInvoke initialize asynch web method call
    2. WaitOne waits for Timeout miliseconds
    3. WaitOne returns false because timeout occured, and wait screen is
    displayed. When user close it the web methos is finished.
    4. result1.IsCompl eted is true so I expect that EndInvoke shall return the
    results but it throws excpetion "timeout" !!!. Why?
    Everything works fine if timeout doesn't occure.

    Thanks for any advise
    Shark

  • Peter Bromberg [C# MVP]

    #2
    Re: WebService and timeout

    Have you tried calling this synchronously? If it is going to time out and
    you need to get your results before you can go any further, calling it
    asynchronously isn't going to help any.
    Peter
    "shark" <mark@poczta.on et.plwrote in message
    news:fva0ja$8am $1@news.onet.pl ...
    Hi.
    >
    I'm dealing with scenario when call to any web method ends up with timeout
    and I try to add the user a chance to retry (wait a little bit)
    My service proxy code looks like this:
    >
    AsyncCallback cb = new AsyncCallback(S erviceCallback) ;
    IAsyncResult result1 = BeginInvoke(met hodName, parameters, cb, this);
    if(result1.IsCo mpleted == false)
    {
    while(true)
    {
    bTO = result1.AsyncWa itHandle.WaitOn e(Timeout, true);
    if(bTO == false)//time out occured
    {
    //display window and ask the user to wait a moment, user press
    OK when it sure that web method finished
    }
    if(result1.IsCo mpleted)
    break;
    }
    object[] ret = EndInvoke(resul t1);// error every time when time out
    occured (bTO = false)
    }
    My scenario is following:
    1. BeginInvoke initialize asynch web method call
    2. WaitOne waits for Timeout miliseconds
    3. WaitOne returns false because timeout occured, and wait screen is
    displayed. When user close it the web methos is finished.
    4. result1.IsCompl eted is true so I expect that EndInvoke shall return the
    results but it throws excpetion "timeout" !!!. Why?
    Everything works fine if timeout doesn't occure.
    >
    Thanks for any advise
    Shark

    Comment

    • shark

      #3
      Re: WebService and timeout

      Yes, synchronously it works fine, but I try to get the user a possibility to
      wait longer than 'timeout'.
      My scenario shall looks:
      1. Init asynchronously call
      2. Wait for results
      3. If timeout goto 2 else if IsCompleted goto 3
      4. Call EndInvoke to get the results.

      It seems that calling EndInvoke in case earlier timeout occured ends up with
      TimeOut exception. Why?

      Thx




      "Peter Bromberg [C# MVP]" <pbromberg@nosp ammin.yahoo.com wrote in message
      news:471442F2-0A7E-4A87-A3F3-F3B53D9D805C@mi crosoft.com...
      Have you tried calling this synchronously? If it is going to time out and
      you need to get your results before you can go any further, calling it
      asynchronously isn't going to help any.
      Peter
      "shark" <mark@poczta.on et.plwrote in message
      news:fva0ja$8am $1@news.onet.pl ...
      >Hi.
      >>
      >I'm dealing with scenario when call to any web method ends up with
      >timeout and I try to add the user a chance to retry (wait a little bit)
      >My service proxy code looks like this:
      >>
      >AsyncCallbac k cb = new AsyncCallback(S erviceCallback) ;
      >IAsyncResult result1 = BeginInvoke(met hodName, parameters, cb, this);
      >if(result1.IsC ompleted == false)
      >{
      > while(true)
      > {
      > bTO = result1.AsyncWa itHandle.WaitOn e(Timeout, true);
      > if(bTO == false)//time out occured
      > {
      > //display window and ask the user to wait a moment, user press
      >OK when it sure that web method finished
      > }
      > if(result1.IsCo mpleted)
      > break;
      > }
      > object[] ret = EndInvoke(resul t1);// error every time when time out
      >occured (bTO = false)
      >}
      >My scenario is following:
      >1. BeginInvoke initialize asynch web method call
      >2. WaitOne waits for Timeout miliseconds
      >3. WaitOne returns false because timeout occured, and wait screen is
      >displayed. When user close it the web methos is finished.
      >4. result1.IsCompl eted is true so I expect that EndInvoke shall return
      >the results but it throws excpetion "timeout" !!!. Why?
      >Everything works fine if timeout doesn't occure.
      >>
      >Thanks for any advise
      >Shark
      >

      Comment

      Working...