private static void Main(string[] args) { var cancellationTokenSource = new CancellationTokenSource(); CancellationToken cancellationToken = cancellationTokenSource.Token; var workStealingTaskScheduler = new WorkStealingTaskScheduler(Environment.ProcessorCount - 1); var bag = new ConcurrentBag <Task>(); IEnumerable <string> bigList = Enumerable.Range(0, 10000).Select(s => s.ToString()); bigList.ToObservable().Buffer(ChunkSize).Subscribe( chunk => bag.Add( Task.Factory.StartNew( () => { foreach (string s in chunk) { Console.WriteLine(s); } Console.WriteLine(String.Empty.PadRight(80, '-')); }, cancellationToken, TaskCreationOptions.None, workStealingTaskScheduler))); Task.WaitAll(bag.ToArray()); }
public override void OnEntry() { this.astarTask = WorkStealingTaskScheduler.Run(() => { return(new Astar().CalculatePath(parent.user.Position, parent.data.targetPos, parent.data.aStarMargin)); }); }