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?
probably a bit rustic…