Question Using timers on Asyncronous requests

danfloun

Member
Joined
Apr 5, 2010
Messages
23
Programming Experience
Beginner
Hi,

I'm using OpenReadAsync to download a string via stream.
Everything works fine until I down the internet connection in my router which causes the request to the URI to timeout, which is fine but it takes too long... about 30 seconds.

I need to initiate my own timer to timeout the request after 10 seconds instead.

Trouble is there is very little on timing out an Async request, furthermore I'm confused as to which type of timer I'm supposed to be using.

I read there are timers for forms, timers best suited to server functions and then system.timers.

Can someone give me any pointers, I'm not certain how to do this.
Alternatively point me to a 'good understandable read'.

Thanks
Danny
 
I got it working using the form timers.

I declared a new instance of webclient using WithEvents and then simply used the timer start() and stop() properties.

Once the interval is reached, I initiated webclient.CancelAsync().

I then check to see if the request was cancelled using;

If e.cancelled then
'do something
End If
'rest of code

Cheers
Danny
 
Back
Top