Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6062169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:01:15+00:00 2026-05-23T09:01:15+00:00

In Silverlight, say we start an async request: var request = WebRequest.Create(uri); and then

  • 0

In Silverlight, say we start an async request:

var request = WebRequest.Create(uri);

and then wait for a response via a delegate

request.BeginGetResponse(getResponseResult => ...

How do we timeout this waitee, to deliver a time-out error signal to the delegate instead? Use a timer? (note: timeout options available in the .net framework are missing in the Silverlight version).

To handle two messages arriving at the same time, we could introduce a Guid filter, and then ignore a 2nd message when/if it was delivered to the delegate. Or in reverse (better), we register an expiring Guid so that the delegate can discard a second message — at least some garbage collection is possible then (although the memory footprint of a delegate has got to be on the small side).

What follows are some notes I’ve made. I haven’t reached a conclusion yet. Any help much appreciated.


My line of enquiry was going to be to implement a timer, notify the callback, and then somehow cancel waiting delegate in request.BeginGetResponse(…).

Note:

  • While the .Net Frame Work 4 implements a timeout on the WebRequest class, the Silverlight version does not.

  • "System.Threading.Task.Wait Method (TimeSpan)" is not available either

QUESTION 1: is there a better way to implement a timeout error to the same delegate target?

QUESTION 2: To cancel the waiting delegate, is it sufficient to use "request.BeginGetResponse(null)"?

QUESTION 3: will a non executed delegate (e.g. getResponseResult => …) cause a small memory leak? Is this just a minor concern?


Information on creating a timer:

  • System.Windows.Threading.DispatcherTimer

  • http://blog.bodurov.com/How-to-Create-setTimeout-Function-in-Silverlight

Some References:

  • http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.binding.opentimeout(v=VS.95).aspx (seems to be WCF related)

  • http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.binding.receivetimeout(v=VS.95).aspx (seems to be WCF related)

  • http://blog.bodurov.com/How-to-Create-setTimeout-Function-in-Silverlight (could be useful)

  • Silverlight, dealing with Async calls (no new information)

  • http://petesbloggerama.blogspot.com/2008/07/omg-silverlight-asynchronous-is-evil.html (I want to deal with Async properly… I’ve got some good techniques, but I want to ensure that I’m using them cleanly. Probably I need to look into delegates more closely).

  • http://msdn.microsoft.com/en-us/library/dd460717.aspx#CommunityContent

  • http://csharperimage.jeremylikness.com/2010/03/sequential-asynchronous-workflows-in.html (some good information. Still haven’t found out what to do about infinitely waiting delegates).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:01:15+00:00Added an answer on May 23, 2026 at 9:01 am

    If you feel like giving reactive extensions a try you will get time out support for cheap. With Rx it will look something like this (not exact code):

    var obsrv = Observable.FromAsyncPattern<...>(Begin..., End...);
    obsrv(...).Timeout(new TimeSpan(0,0,5)).Subscribe(() => DoThings());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I use the navigation framework in silverlight and say mainFrame.Navigate(URI), does this always
Is Silverlight a subset of WPF? If i learn WPF then can i say
Say I had (foolishly) setup a Silverlight project in VS and failed to setup
Let's say I have a situation in Silverlight where there is a background thread
For example: First, say I have a Silverlight app with Windowless=true so that I
Is there a usable equivalent of AppDomain.UnhandledException for Silverlight? I say usable, because, although
I'll preface this and say that I'm new to Silverlight development by about week
So, lets say I write a binding in Silverlight that cannot be resolved. I
How hard is it to transition from WPF to Silverlight? Would you say that
Say I have a Silverlight Child Windows that uses as a web browser to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.