public async Task CanRunJobsWithLocks() { var job = new WithLockingJob(Log); Assert.Equal(0, job.RunCount); await job.RunAsync(); Assert.Equal(1, job.RunCount); await job.RunContinuousAsync(iterationLimit: 2); Assert.Equal(3, job.RunCount); await Run.InParallelAsync(2, i => job.RunAsync()); Assert.Equal(4, job.RunCount); }
public async Task CanRunJobsWithLocks() { var job = new WithLockingJob(); Assert.Equal(0, job.RunCount); await job.RunAsync(); Assert.Equal(1, job.RunCount); await job.RunContinuousAsync(iterationLimit: 2); Assert.Equal(3, job.RunCount); await Run.InParallel(2, async i => await job.RunAsync()); Assert.Equal(4, job.RunCount); }
public void CanRunJobsWithLocks() { var job = new WithLockingJob(); Assert.Equal(0, job.RunCount); job.Run(); Assert.Equal(1, job.RunCount); job.RunContinuous(iterationLimit: 2); Assert.Equal(3, job.RunCount); Task.Run(() => job.Run()); Task.Run(() => job.Run()); Thread.Sleep(200); Assert.Equal(4, job.RunCount); }