Ejemplo n.º 1
0
        /// <summary>
        /// Wait all tasks completition with try|cathc block.
        /// </summary>
        /// <returns>True if thread terminated because of timeout.</returns>
        public async Task <bool> AwaitAllPending(TimeSpan?timeout = null)
        {
            var res = await TaskExt.WhenAll(_pendingTasks, timeout);

            foreach (var t in _pendingTasks)
            {
                if (t.IsCanceled || t.IsCompleted || t.IsFaulted)
                {
                    _pendingTasks.TryRemove(t);
                }
            }
            return(res);
        }