Esempio n. 1
0
        public async Task <IReadOnlyList <SniHostnameIpAddressPair> > ExecuteAsync(CancellationToken cancel = default)
        {
            StartFlag.FirstCallOrThrowException();

            List <Task> taskList = new List <Task>();

            for (int i = 0; i < this.MaxConcurrentTasks; i++)
            {
                Task t = WorkerTaskAsync(cancel);

                taskList.Add(t);
            }

            foreach (Task t in taskList)
            {
                await t._TryWaitAsync(true);
            }

            return(ResultList.ToList());
        }
Esempio n. 2
0
        public async Task <IReadOnlyList <SslCertCollectorItem> > ExecuteAsync(CancellationToken cancel = default)
        {
            int totalCount = Queue.Count;

            StartFlag.FirstCallOrThrowException();

            List <Task> taskList = new List <Task>();

            for (int i = 0; i < this.MaxConcurrentTasks; i++)
            {
                Task t = WorkerTaskAsync(cancel);

                taskList.Add(t);
            }

            CancellationTokenSource done = new CancellationTokenSource();

            TaskUtil.StartAsyncTaskAsync(async() =>
            {
                CancellationToken doneCancel = done.Token;

                while (doneCancel.IsCancellationRequested == false)
                {
                    await doneCancel._WaitUntilCanceledAsync(250);

                    int completed = totalCount - Queue.Count;

                    Con.WriteLine("{0} / {1}", completed._ToString3(), totalCount._ToString3());
                }
            })._LaissezFaire(true);

            foreach (Task t in taskList)
            {
                await t._TryWaitAsync(true);
            }

            done._TryCancelNoBlock();

            return(ResultList.ToList());
        }