Webrequest.Timeout for asynchronous calls?

Discussion in 'Questions (Windows Mobile)' started by N1c0_ds, Mar 7, 2009.

  1. N1c0_ds

    N1c0_ds Active Member Licensed User

    I'm trying to set a timeout for my HTTP request while using an async call (getasyncresponse). However I noticed Timeout doesn't work for async calls.
     
    Last edited: Mar 9, 2009
  2. Erel

    Erel Administrator Staff Member Licensed User

    As this call is not a blocking call you can decide to ignore it and don't handle the response.
     
  3. N1c0_ds

    N1c0_ds Active Member Licensed User

    But it's used to download screenshots, files and information. I must be able to do something when there's no connection (put a filler screenshot image, stop the download and show an error message).

    I really need to have a timeout. Maybe using timers? :sign0085: Is there any way to stop a response call? I would stop the call after 5 seconds using a timer's tick event.
     
    Last edited: Mar 7, 2009
  4. Erel

    Erel Administrator Staff Member Licensed User

    Currently it is not possible to cancel the request. However you can use a timer to test if the response event was not fired after 30 or 60 seconds (5 seconds is not enough) show an error message and later ignore the response event if it will fire.
     
  5. N1c0_ds

    N1c0_ds Active Member Licensed User

    Alright, I'll see what I can do and report back. Thanks!
     
  6. N1c0_ds

    N1c0_ds Active Member Licensed User

    How would you do that
     
    Last edited: Mar 9, 2009
  7. Erel

    Erel Administrator Staff Member Licensed User

    Somthing like:
    Code:
    Sub Globals
       ignoreResponse = 
    false
    End Sub

    Sub App_Start
         Form1.Show
         request.New1(URL)
         response.New1
         request.GetAsyncResponse
          ignoreResponse = 
    false
          Timer1.Enabled = 
    true 'interval = 30000

    End Sub

    Sub Timer1_Tick
     Timer1.Enabled = 
    false
     ignoreRequest = 
    true
     
    msgbox("Error connecting to site.")
    End Sub


    Sub request_Response
     
    if ignoreRequest then return
     ...
    End Sub
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice