Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
997 B
4
Indexable
Never
using System.Diagnostics;

namespace CheatEngine
{
    public class ParallelVsTaskVsParallelTask
    {
        public class Tasks
        {
            List<float> list = new List<float>();

            private int[]? _dataSet;
            public void GlobalSetup()
            {
                _dataSet = Enumerable.Range(0, 1).ToArray();
            }

            public async Task<List<float>> ParallelForEach()
            {
                await Parallel
                .ForEachAsync(
                _dataSet!,
                CancellationToken.None,
                (_, ct) =>
                {
                    for (int i = 0; i < 1000; i++)
                    {
                        list.Add(RWMem.rw("X"));
                    }
                    Debug.WriteLine("a");
                    return ValueTask.CompletedTask;
                });
                Debug.WriteLine("b");
                return list;
            }
        }
    }
}
Leave a Comment