public void TwoInstanceTest() { ReaderWriterWithClone rw1 = new ReaderWriterWithClone(); ReaderWriterWithClone rw2 = new ReaderWriterWithClone(); Barrier barrier = new Barrier( 2 ); Task t1 = new Task( () => rw1.Write( 0, barrier.SignalAndWait ) ); Task t2 = new Task( () => rw2.Write( 0, barrier.SignalAndWait ) ); t1.Start(); t2.Start(); Assert.True( Task.WaitAll( new[] { t1, t2 }, 1000 ) ); }
public void TwoInstanceTest() { ReaderWriterWithClone rw1 = new ReaderWriterWithClone(); ReaderWriterWithClone rw2 = new ReaderWriterWithClone(); Barrier barrier = new Barrier(2); Task t1 = new Task(() => rw1.Write(0, barrier.SignalAndWait)); Task t2 = new Task(() => rw2.Write(0, barrier.SignalAndWait)); t1.Start(); t2.Start(); Assert.True(Task.WaitAll(new[] { t1, t2 }, 1000)); }
public void MemberwiseCloneWithInitializationTest() { ReaderWriterWithClone rw1 = new ReaderWriterWithClone(); ReaderWriterWithClone rw2 = rw1.InitilizedClone(); Barrier barrier = new Barrier(2); Task t1 = new Task(() => rw1.Write(0, barrier.SignalAndWait)); Task t2 = new Task(() => rw2.Write(0, barrier.SignalAndWait)); t1.Start(); t2.Start(); Assert.True(Task.WaitAll(new[] { t1, t2 }, 1000)); }