You've already forked linux-packaging-mono
Imported Upstream version 4.2.0.179
Former-commit-id: 0a113cb3a6feb7873f632839b1307cc6033cd595
This commit is contained in:
committed by
Jo Shields
parent
183bba2c9a
commit
6992685b86
@ -61,6 +61,24 @@ namespace MonoTests.System.Threading
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void QueueUserWorkItem ()
|
||||
{
|
||||
int n = 100000;
|
||||
int total = 0, sum = 0;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
if (i % 2 == 0)
|
||||
ThreadPool.QueueUserWorkItem (_ => { Interlocked.Decrement (ref sum); Interlocked.Increment (ref total); });
|
||||
else
|
||||
ThreadPool.QueueUserWorkItem (_ => { Interlocked.Increment (ref sum); Interlocked.Increment (ref total); });
|
||||
}
|
||||
var start = DateTime.Now;
|
||||
while ((total != n || sum != 0) && (DateTime.Now - start).TotalSeconds < 60)
|
||||
Thread.Sleep (1000);
|
||||
Assert.IsTrue (total == n, "#1");
|
||||
Assert.IsTrue (sum == 0, "#2");
|
||||
}
|
||||
|
||||
#if NET_4_0
|
||||
event WaitCallback e;
|
||||
|
||||
|
Reference in New Issue
Block a user