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 8089655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:28:03+00:00 2026-06-05T19:28:03+00:00

I am looking to implement some throttling behavior into one of my viewmodels. It’s

  • 0

I am looking to implement some throttling behavior into one of my viewmodels. It’s a silverlight application, however I don’t think that’s particularly important.

Consider a class with three properties:

  • Property1
  • Property2
  • Property3

Whenever one of these properties is updated, a refresh is neccessary.

private void Refresh()
{
    //Call out to the server, do something when it comes back
}

My goals are as follows:

  • If a Refresh is in progress, we should ideally cancel the call to the server, and issue a new request
  • If a property is changed, we should leave some small window of time (perhaps 0.1 seconds) where we wait for additional changes. This way, if multiple properties are changed rapidly (for example, programmatically) we don’t spam the server with requests. It’s OK for that 0.1 second window to reset on each change, but not required.

If it matters, I am using a ChannelFactory implementation for the server call.

What kind of patterns can I use to accomplish this? Is this something reactive extensions can help me with?

Edit:

Marking Paul’s answer as correct. While ReactiveUI doesn’t currently work against silverlight5, it clearly outlines the approach / composition steps to solving the problem using Rx.

  • 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-06-05T19:28:05+00:00Added an answer on June 5, 2026 at 7:28 pm

    Here’s how you would do this with ReactiveUI:

    IObservable<TheData> FetchNewData() 
    {
        // TODO: Implement me
    }
    
    this.WhenAny(x => x.Property1, x => x.Property2, x => x.Property3, (x,y,z) => Unit.Default)
        .Throttle(TimeSpan.FromMilliseconds(200), RxApp.DeferredScheduler)
        .Select(x => FetchNewData())
        .Switch()    // We only care about the req corresp. to latest values of Prop1-3
        .ToProperty(this, x => x.Data);
    

    Update: Here’s how to guarantee that there is only one running at a time, with the caveat that you may get out-of-order results.

    this.WhenAny(x => x.Property1, x => x.Property2, x => x.Property3, (x,y,z) => Unit.Default)
        .Throttle(TimeSpan.FromMilliseconds(200), RxApp.DeferredScheduler)
        .Select(_ => Observable.Defer(() => FetchNewData()))
        .Merge(1)
        .ToProperty(this, x => x.Data);
    

    The behavior you describe, would actually be perhaps not desireable, since if the properties keep changing, you’ll end up with a queue of old requests to issue – you could optimize this if you made something like a “BufferingSwitch()” operator that didn’t return its results until it was sure there were no changes – that’d actually be cool to write.

    Moral of the story, Async Is Complicated™ 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking to implement the jQuery UI so that the slider bar fills one
I'm looking to implement a fairly basic jQuery slideshow. One that automatically loops through
We are looking to implement some complex charting graphs for a new application we
I am looking for open source JCE libraries that implement some of the more
I'm looking to implement some templates in a web application and wanted to utilize
Looking at Thrift and Google Protocol Buffers to implement some quick RPC code. Thrift
I'm looking to implement content negotiation on some resources in a Rails app. I'm
Looking for some advice on the best way to implement localization along with client
I'm looking for some suggestions as to how I could implement a World Map
Looking to implement a RIA (rich internet application) either as a java (JWS) application

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.