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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:48:40+00:00 2026-06-03T12:48:40+00:00

I currently have a windows service that runs every 5 minutes. The code selects

  • 0

I currently have a windows service that runs every 5 minutes. The code selects rows from a database for processing. There is a cap (maximum rows allowed to be selected) so the number of rows selected could be anywhere from 0-100.

I am looking to do some processing on these rows based on a random percentage selection.

  • Task 1 25%
  • Task 2 50%
  • Task 3 100%

For simplicity, let’s assume the service selects 100 rows, then 25 randomly selected rows will run Task 1, 50 randomly selected rows will run Task 2, and all of the rows will run Task 3.

The code I have currently looks something like:

var rows = repository.GetRows(100);

foreach(var row in rows)
{
    task1.Run(row);
    task2.Run(row);
    task3.Run(row);
}

This will run all three tasks on all rows. How would I go about only selecting the allotted percentages to each task?

  • 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-03T12:48:42+00:00Added an answer on June 3, 2026 at 12:48 pm

    probably a bit rustic…

    var rows = repository.GetRows(100);
    
    rows.OrderBy(Guid.NewGuid()).Take(25).ToList().ForEach(m => task1.Run(m));
    rows.OrderBy(Guid.NewGuid()).Take(50).ToList().ForEach(m => task2.Run(m));
    rows.ToList().ForEach(m => task3.Run(m));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We currently have a production application that runs as a windows service. Many times
We currently have an automated system that runs as a service for processing satellite
I have a windows service that runs every night between 3am and 5am. When
We have a C# Windows service that currently processes all the PDFs by reading
I have a game that currently runs under Windows and Mac OS X and
I currently have a Windows Service which continually runs throughout the day. It has
We currently have an application (Windows service) that connects to another of our applications
I have a windows service that runs fine, but I have to have it
I have a server written in Java that runs as a Windows service (thanks
Currently, I have a project with a Windows Service. I also created another Setup

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.