Ejemplo n.º 1
0
    public async Task OnEnqueuedAlreadyDispatched()
    {
        var  queue         = new DerivedQueue <int>();
        bool callbackFired = false;

        queue.OnEnqueuedDelegate = (value, alreadyDispatched) =>
        {
            Assert.Equal(5, value);
            Assert.True(alreadyDispatched);
            callbackFired = true;
        };

        Task <int>?dequeuer = queue.DequeueAsync();

        queue.Enqueue(5);
        Assert.True(callbackFired);
        Assert.Equal(5, await dequeuer.WithTimeout(UnexpectedTimeout));
    }
Ejemplo n.º 2
0
        public void OnEnqueuedAlreadyDispatched()
        {
            var  queue         = new DerivedQueue <int>();
            bool callbackFired = false;

            queue.OnEnqueuedDelegate = (value, alreadyDispatched) =>
            {
                Assert.Equal(5, value);
                Assert.True(alreadyDispatched);
                callbackFired = true;
            };

            var dequeuer = queue.DequeueAsync();

            queue.Enqueue(5);
            Assert.True(callbackFired);
            Assert.True(dequeuer.IsCompleted);
        }