Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- // var cpuCores = 8;
- // var threads = cpuCores - 1;
- // var settingThreadOption = System.Threading.ThreadPool.SetMaxThreads(
- // threads, threads);
- // var stopWatch = System.Diagnostics.Stopwatch.StartNew();
- var strings = new List<string>();
- var recordTimedList = new ConcurrentBag<string>();
- using (var finished = new System.Threading.CountdownEvent(1))
- {
- foreach (var @string in strings)
- {
- finished.AddCount();
- System.Threading.ThreadPool.QueueUserWorkItem((System.Threading.WaitCallback)(async (state) =>
- {
- try
- {
- await WriteAsync(@string);
- recordTimedList.Add(@string);
- }
- finally
- {
- finished.Signal();
- }
- }));
- }
- finished.Signal();
- finished.Wait();
- }
- // stopWatch.Stop();
- // System.Diagnostics.Debug.WriteLine(
- // $"Elapsed Time: {stopWatch.ElapsedMilliseconds} ms");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement