Exemple #1
0
    public IEnumerator TestMultiThreadParallelTaskReset()
    {
        var test = new MultiThreadedParallelTaskCollection("test", 4, false);

        Token token = new Token();

        int done = 0;

        test.onComplete += () => done++;
        test.Add(new WaitEnumerator(token));
        test.Add(new WaitEnumerator(token));
        test.Add(new WaitEnumerator(token));
        test.Add(new WaitEnumerator(token));

        test.Run();

        yield return(new WaitForSeconds(0.5f));

        token.count = 3;

        test.Stop();

        test.Complete();
        test.Dispose();

        Assert.That(done == 1);
        Assert.AreEqual(4, token.count);
    }
Exemple #2
0
    public IEnumerator TestStopMultiThreadParallelTask()
    {
        var test = new MultiThreadedParallelTaskCollection("test", 4, false);

        Token token = new Token();
        bool  done  = false;

        test.onComplete += () => done = true;
        test.Add(new WaitEnumerator(token));
        test.Add(new WaitEnumerator(token));
        test.Add(new WaitEnumerator(token));
        test.Add(new WaitEnumerator(token));

        test.Run();

        yield return(new WaitForSeconds(0.5f));

        test.Stop();
        test.Dispose();

        Assert.That(done, Is.False);
        Assert.AreEqual(token.count, 0);
    }