예제 #1
0
        public async Task <ReadOnlyCollection <Reaction> > CollectAsync(ReactionCollectRequest request)
        {
            this._requests.Add(request);
            var result = (ReadOnlyCollection <Reaction>)null;

            try
            {
                await request._tcs.Task.ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                this._client.Logger.LogError(InteractivityEvents.InteractivityCollectorError, ex, "Exception occurred while collecting reactions");
            }
            finally
            {
                result = new ReadOnlyCollection <Reaction>(new HashSet <Reaction>(request._collected).ToList());
                request.Dispose();
                this._requests.TryRemove(request);
            }
            return(result);
        }
예제 #2
0
        public async Task <ReadOnlyCollection <Reaction> > CollectAsync(ReactionCollectRequest request)
        {
            this._requests.Add(request);
            var result = (ReadOnlyCollection <Reaction>)null;

            try
            {
                await request._tcs.Task;
            }
            catch (Exception ex)
            {
                this._client.DebugLogger.LogMessage(LogLevel.Error, "Interactivity",
                                                    $"Something went wrong collecting reactions with exception {ex.GetType().Name}.", DateTime.Now);
            }
            finally
            {
                result = new ReadOnlyCollection <Reaction>(new HashSet <Reaction>(request._collected).ToList());
                request.Dispose();
                this._requests.TryRemove(request);
            }
            return(result);
        }