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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:58:31+00:00 2026-05-27T10:58:31+00:00

I have an event stream which contains the values for some variables. The values

  • 0

I have an event stream which contains the values for some variables. The values change every second. Each variable has high limit, low limit and a threshold period defined.

For example, say Variable1 has high limit = 95, low limit = 5 and threshold = 5 seconds.

So if the values for Variable1 stay above 95 (high limit) for the threshold period (5 seconds), then we should create an output event.

I am able to create query for checking the individual events (if they have crossed the limits), but I am not sure how to create a windowed query to check if the limits were violated for the threshold period.

Thanks,

  • 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-27T10:58:31+00:00Added an answer on May 27, 2026 at 10:58 am

    Well, not entirely a Linq query, but should do the trick:

    public IEnumerable<IEnumerable<int>> GetWindows(IEnumerable<int> events)
    {
        while (events.Any())
        {
            events = events.SkipWhile(x => x > 5 && x < 95);
            if (events.Any())
            {
                var isLow = events.First() <= 5;
                var res = events.TakeWhile(x => isLow ? x <= 5 : x >= 95).ToList();
                if (res.Count >= 5)
                    yield return res;
                events = events.Skip(res.Count);
            }
        }
    }
    

    Basically:

    • Skip all uninteresting events
    • Take the window and yield it if more entries than threshold period
    • Advance the enumeration by skipping the window

    The you can use it like this:

    foreach (var window in GetWindows(events))
    {
       ... raise event
    }
    

    Note: If your events come in as a potentially infinite stream and your event windows can get very large then you won’t get the window returned until it’s fully consumed which might take some time and memory. You could break the TakeWhile part after having seen 5 elements and then yield there and simply skip the rest of the window afterwards. It depends a bit of what you want to do exactly.

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

Sidebar

Related Questions

I'm considering the following: I have some data stream which I'd like to protect
I have a Custom DirectShow Video Renderer Filter which has some extended features over
Input rz value In the head I have: Event.observe(window, 'load', function() { $$(input).each(function(field){ Event.observe(field,
I have some event handler on a boundary class that manages a persistence mechanism
I have quite some amount of streamable data (>100MB), which, for the sake of
I have a Connection class which reads packets (commands) from a text stream and
I have an ISAPI filter for IIS 6 which does some custom processing using
I have event manager process that dispatches events to subscribers (e.g. http_session_created, http_sesssion_destroyed). If
I have an event handler that needs to determine a type and execute code
I have an event handler that will remove an element from a list of

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.