public async Task AddTaskToLegacyDoubleBufferWithReaderWriterLockSlimMultiThread() { var foo = new Foo(); var doubleBuffer = new DoubleBufferWithReaderWriterLockSlim <List <Foo>, Foo>(new List <Foo>(MaxCount), new List <Foo>(MaxCount)); var threadCount = 10; var taskList = new Task[threadCount]; for (int j = 0; j < threadCount; j++) { var task = Task.Run(() => { for (int i = 0; i < MaxCount / threadCount; i++) { doubleBuffer.Add(foo); } }); taskList[j] = task; } await Task.WhenAll(taskList); }
public void AddTaskToLegacyDoubleBufferWithReaderWriterLockSlim() { var foo = new Foo(); var doubleBuffer = new DoubleBufferWithReaderWriterLockSlim <List <Foo>, Foo>(new List <Foo>(MaxCount), new List <Foo>(MaxCount)); for (int i = 0; i < MaxCount; i++) { doubleBuffer.Add(foo); } }