示例#1
0
        public void Load(Hit hit, string url)
        {
            var currentScheduler = TaskScheduler.FromCurrentSynchronizationContext();

            Task.Run(async() =>
            {
                //load cover
                CoverLoadSemaphore.Wait();
                var coverData = new CoverData();
                //laod cover
                coverData.Image = await CoverService.LoadCoverAsyncLazyCached(url);
                CoverLoadSemaphore.Release();
                return(coverData);
            }).ContinueWith(coverTask =>
            {
                //if successfull
                if (coverTask.IsCompleted && coverTask.Result != null)
                {
                    //set image
                    var coverData  = coverTask.Result;
                    hit.CoverImage = coverData.Image;
                }
            }, currentScheduler);
        }