当前位置: 首页>>代码示例>>C#>>正文


C# AsyncQueue.TryDequeue方法代码示例

本文整理汇总了C#中AsyncQueue.TryDequeue方法的典型用法代码示例。如果您正苦于以下问题:C# AsyncQueue.TryDequeue方法的具体用法?C# AsyncQueue.TryDequeue怎么用?C# AsyncQueue.TryDequeue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AsyncQueue的用法示例。


在下文中一共展示了AsyncQueue.TryDequeue方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Count_nonempty

 public void Count_nonempty()
 {
     var queue = new AsyncQueue<string>();
     queue.Enqueue("A");
     queue.Enqueue("B");
     queue.Enqueue("C");
     queue.Enqueue("D");
     Assert.IsTrue(queue.TryDequeue());
     Assert.AreEqual(3, queue.Count);
 }
开发者ID:timothy-shields,项目名称:async-data-structures,代码行数:10,代码来源:AsyncQueueTests.cs

示例2: DequeueCompilationEvents

        private static bool DequeueCompilationEvents(AsyncQueue<CompilationEvent> eventQueue, out bool compilationStartedFired, out HashSet<string> declaredSymbolNames, out HashSet<string> completedCompilationUnits)
        {
            compilationStartedFired = false;
            declaredSymbolNames = new HashSet<string>();
            completedCompilationUnits = new HashSet<string>();
            if (eventQueue.Count == 0)
            {
                return false;
            }

            CompilationEvent compEvent;
            while (eventQueue.TryDequeue(out compEvent))
            {
                if (compEvent is CompilationStartedEvent)
                {
                    Assert.False(compilationStartedFired, "Unexpected multiple compilation stated events");
                    compilationStartedFired = true;
                }
                else
                {
                    var symbolDeclaredEvent = compEvent as SymbolDeclaredCompilationEvent;
                    if (symbolDeclaredEvent != null)
                    {
                        var added = declaredSymbolNames.Add(symbolDeclaredEvent.Symbol.Name);
                        Assert.True(added, "Unexpected multiple symbol declared events for symbol " + symbolDeclaredEvent.Symbol);
                    }
                    else
                    {
                        var compilationCompeletedEvent = compEvent as CompilationUnitCompletedEvent;
                        if (compilationCompeletedEvent != null)
                        {
                            Assert.True(completedCompilationUnits.Add(compilationCompeletedEvent.CompilationUnit.FilePath));
                        }
                    }
                }
            }

            return true;
        }
开发者ID:gustavoasoares,项目名称:roslyn,代码行数:39,代码来源:GetDiagnosticsTests.cs

示例3: FreeEventQueue

        private void FreeEventQueue(AsyncQueue<CompilationEvent> eventQueue)
        {
            if (eventQueue == null || ReferenceEquals(eventQueue, s_EmptyEventQueue))
            {
                return;
            }

            Debug.Assert(!eventQueue.IsCompleted);
            if (eventQueue.Count > 0)
            {
                CompilationEvent discarded;
                while (eventQueue.TryDequeue(out discarded)) ;
            }

            s_eventQueuePool.Free(eventQueue);
        }
开发者ID:JRobertGit,项目名称:roslyn,代码行数:16,代码来源:CompilationWithAnalyzers.cs

示例4: FreeEventQueue

        private static void FreeEventQueue(AsyncQueue<CompilationEvent> eventQueue, ObjectPool<AsyncQueue<CompilationEvent>> eventQueuePool)
        {
            if (eventQueue == null || ReferenceEquals(eventQueue, s_EmptyEventQueue))
            {
                return;
            }

            if (eventQueue.Count > 0)
            {
                CompilationEvent discarded;
                while (eventQueue.TryDequeue(out discarded)) ;
            }

            if (!eventQueue.IsCompleted)
            {
                eventQueuePool.Free(eventQueue);
            }
            else
            {
                eventQueuePool.ForgetTrackedObject(eventQueue);
            }
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:22,代码来源:CompilationWithAnalyzers.cs

示例5: TryDequeueAfterComplete

        public async Task TryDequeueAfterComplete()
        {
            var queue = new AsyncQueue<int>();
            queue.Enqueue(13);
            queue.Complete();
            await queue.WhenCompletedTask.ConfigureAwait(false);

            int value;
            Assert.True(queue.TryDequeue(out value));
            Assert.Equal(13, value);
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:11,代码来源:AsyncQueueTests.cs

示例6: TryDequeue

 public void TryDequeue()
 {
     var queue = new AsyncQueue<int>();
     int value;
     Assert.False(queue.TryDequeue(out value));
     queue.Enqueue(13);
     Assert.True(queue.TryDequeue(out value));
     Assert.Equal(13, value);
 }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:9,代码来源:AsyncQueueTests.cs

示例7: TryDequeue_nonempty

 public void TryDequeue_nonempty()
 {
     var queue = new AsyncQueue<string>();
     queue.Enqueue("A");
     string value;
     Assert.IsTrue(queue.TryDequeue(out value));
     Assert.AreEqual("A", value);
     Assert.AreEqual(0, queue.Count);
 }
开发者ID:timothy-shields,项目名称:async-data-structures,代码行数:9,代码来源:AsyncQueueTests.cs

示例8: TryDequeue_empty

 public void TryDequeue_empty()
 {
     var queue = new AsyncQueue<string>();
     Assert.IsFalse(queue.TryDequeue());
 }
开发者ID:timothy-shields,项目名称:async-data-structures,代码行数:5,代码来源:AsyncQueueTests.cs


注:本文中的AsyncQueue.TryDequeue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。