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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:56:17+00:00 2026-06-08T12:56:17+00:00

Throttle method skips values from an observable sequence if others follow too quickly. But

  • 0

Throttle method skips values from an observable sequence if others follow too quickly. But I need a method to just delay them. That is, I need to set a minimum delay between items, without skipping any.

Practical example: there’s a web service which can accept requests no faster than once a second; there’s a user who can add requests, single or in batches. Without Rx, I’ll create a list and a timer. When users adds requests, I’ll add them to the list. In the timer event, I’ll check wether the list is empty. If it is not, I’ll send a request and remove the corresponding item. With locks and all that stuff. Now, with Rx, I can create Subject, add items when users adds requests. But I need a way to make sure the web service is not flooded by applying delays.

I’m new to Rx, so maybe I’m missing something obvious.

  • 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-08T12:56:18+00:00Added an answer on June 8, 2026 at 12:56 pm

    There’s a fairly easy way to do what you want using an EventLoopScheduler.

    I started out with an observable that will randomly produce values once every 0 to 3 seconds.

    var rnd = new Random();
    
    var xs =
        Observable
            .Generate(
                0,
                x => x < 20,
                x => x + 1,
                x => x,
                x => TimeSpan.FromSeconds(rnd.NextDouble() * 3.0));
    

    Now, to make this output values immediately unless the last value was within a second ago I did this:

    var ys =
        Observable.Create<int>(o =>
        {
            var els = new EventLoopScheduler();
            return xs
                .ObserveOn(els)
                .Do(x => els.Schedule(() => Thread.Sleep(1000)))
                .Subscribe(o);
        });
    

    This effectively observes the source on the EventLoopScheduler and then puts it to sleep for 1 second after each OnNext so that it can only begin the next OnNext after it wakes up.

    I tested that it worked with this code:

    ys
        .Timestamp()
        .Select(x => x.Timestamp.Second + (double)x.Timestamp.Millisecond/1000.0)
        .Subscribe(x => Console.WriteLine(x));
    

    I hope this helps.

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

Sidebar

Related Questions

Underscore provides the method, throttle. From their docs: Creates and returns a new, throttled
I need a component/class that throttles execution of some method to maximum M calls
From http://fullthrottledevelopment.com/php-nonce-library#download , there is a PHP nonce library, but there are a few
I'd like to be able to throttle login attempts based on failed attempts but
The logging docs say that calling the logging.disable(lvl) method can temporarily throttle logging output
On my site I need to throttle user requests for various reasons: Prevent overquerying
Is there any way to throttle a HttpWebRequest? I can call GetResponse() but that
I see from http://msdn.microsoft.com/en-us/library/aa140060(v=office.10).aspx that data throttle value for Excel 2002 is 2 seconds.
Yesterday, I began encountering '999' errors on Yahoo-Pipes. It looks like they throttle requests
Given an IObservable<T> is there a way to use Throttle behaviour (reset a timer

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.