public async Task <IEnumerable <ChannelInfo> > GetChannelsAsync(CancellationToken cancellationToken)
        {
            int timeOut = await WaitForInitialLoadTask(cancellationToken);

            if (timeOut == -1 || cancellationToken.IsCancellationRequested)
            {
                _logger.LogInformation("[TVHclient] GetChannelsAsync, call canceled or timed out - returning empty list.");
                return(new List <ChannelInfo>());
            }

            TaskWithTimeoutRunner <IEnumerable <ChannelInfo> > twtr   = new TaskWithTimeoutRunner <IEnumerable <ChannelInfo> >(TIMEOUT);
            TaskWithTimeoutResult <IEnumerable <ChannelInfo> > twtRes = await
                                                                        twtr.RunWithTimeout(_htsConnectionHandler.BuildChannelInfos(cancellationToken));

            if (twtRes.HasTimeout)
            {
                return(new List <ChannelInfo>());
            }

            var list = twtRes.Result.ToList();

            foreach (var channel in list)
            {
                if (string.IsNullOrEmpty(channel.ImageUrl))
                {
                    channel.ImageUrl = _htsConnectionHandler.GetChannelImageUrl(channel.Id);
                }
            }

            return(list);
        }
示例#2
0
        public async Task <IEnumerable <ChannelInfo> > GetChannelsAsync(CancellationToken cancellationToken)
        {
            int timeOut = await WaitForInitialLoadTask(cancellationToken);

            if (timeOut == -1 || cancellationToken.IsCancellationRequested)
            {
                _logger.Info("[TVHclient] GetChannelsAsync, call canceled or timed out - returning empty list.");
                return(new List <ChannelInfo>());
            }

            TaskWithTimeoutRunner <IEnumerable <ChannelInfo> > twtr   = new TaskWithTimeoutRunner <IEnumerable <ChannelInfo> >(TIMEOUT);
            TaskWithTimeoutResult <IEnumerable <ChannelInfo> > twtRes = await
                                                                        twtr.RunWithTimeout(_htsConnectionHandler.BuildChannelInfos(cancellationToken));

            if (twtRes.HasTimeout)
            {
                return(new List <ChannelInfo>());
            }

            return(twtRes.Result);
        }