Exemple #1
0
        public async Task <ReadOnlyCollection <T> > CollectMatches(CollectRequest <T> request)
        {
            ReadOnlyCollection <T> result = null;

            this._collectrequests.Add(request);
            try
            {
                await request._tcs.Task.ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                this._client.Logger.LogError(InteractivityEvents.InteractivityWaitError, ex, "An exception occurred while collecting from {0}", typeof(T).Name);
            }
            finally
            {
                result = new ReadOnlyCollection <T>(new HashSet <T>(request._collected).ToList());
                request.Dispose();
                this._collectrequests.TryRemove(request);
            }
            return(result);
        }
Exemple #2
0
        public async Task <ReadOnlyCollection <T> > CollectMatches(CollectRequest <T> request)
        {
            ReadOnlyCollection <T> result = null;

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