Created
May 6, 2014 11:14
-
-
Save OlegJakushkin/5298e94361de68ebc175 to your computer and use it in GitHub Desktop.
basic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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