Skip to content

Instantly share code, notes, and snippets.

@OlegJakushkin
Created May 6, 2014 11:14
Show Gist options
  • Save OlegJakushkin/5298e94361de68ebc175 to your computer and use it in GitHub Desktop.
Save OlegJakushkin/5298e94361de68ebc175 to your computer and use it in GitHub Desktop.
basic
using System;
using System.Threading;
using System.Collections.Generic;
using System.Linq;
class Box
{
private static readonly Random RandomNumberGenerator = new Random();
public int SomeRandomValue
{
get
{
Thread.Sleep(1000);
return RandomNumberGenerator.Next(1, 100000);
}
}
}
namespace ThreadingExamples
{
static class Programm
{
static void Main()
{
var items = new List<Box>();
for (var i = 0; i < 10; ++i)
{
items.Add(new Box());
}
var hasSomeValue = items.AsParallel()
.Any(box => box.SomeRandomValue == 99999);
Console.WriteLine(hasSomeValue);
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment