public async Task <string> GetLastElementAsync(int sleepTime)
        {
            await CommonService.WaitInThread(sleepTime);

            if (stack.TryPeek(out string lastElement))
            {
                return(lastElement);
            }
            return(string.Empty);
        }
        public async Task <string> GetAndDeleteFirstElementAsync(int sleepTime)
        {
            await CommonService.WaitInThread(sleepTime);

            if (queue.TryDequeue(out string firstElement))
            {
                return(firstElement);
            }

            return(string.Empty);
        }
        public async Task <string> GetValueAndDeleteAsync(int key, int sleepTime)
        {
            await CommonService.WaitInThread(sleepTime);

            if (dictionary.TryRemove(key, out string value))
            {
                return(value);
            }

            return(string.Empty);
        }
        public async Task <string> GetParticipantAsync(int sleepTime)
        {
            await CommonService.WaitInThread(sleepTime);

            if (_participants.TryPeek(out string participant))
            {
                return(participant);
            }

            return(string.Empty);
        }
        public async Task AddElementAsync(string name, int sleepTime)
        {
            await CommonService.WaitInThread(sleepTime);

            queue.Enqueue(name);
        }
Esempio n. 6
0
        public async Task <BlockingCollection <string> > GetParticipantsAsync(int sleepTime)
        {
            await CommonService.WaitInThread(sleepTime);

            return(_participantWithLimit);
        }
Esempio n. 7
0
        public async Task AddParticipantAsync(string participantName, int sleepTime)
        {
            await CommonService.WaitInThread(sleepTime);

            _participantWithLimit.Add(participantName);
        }
        public async Task UpdateItemAsync(int key, string oldValue, string newValue, int sleepTime)
        {
            await CommonService.WaitInThread(sleepTime);

            dictionary.TryUpdate(key, newValue, oldValue);
        }
        public async Task AddItemAsync(int key, string value, int sleepTime)
        {
            await CommonService.WaitInThread(sleepTime);

            dictionary.TryAdd(key, value);
        }
        public async Task AddElementsAsync(string[] names, int sleepTime)
        {
            await CommonService.WaitInThread(sleepTime);

            stack.PushRange(names);
        }
        public async Task AddElementAsync(string name, int sleepTime)
        {
            await CommonService.WaitInThread(sleepTime);

            stack.Push(name);
        }