/// <summary> /// Main worker thread logic for thumbnailer /// </summary> private void ThumbnailDownloaderMain() { try { // keep waiting for new work items until the queue is terminated // via the ThreadSafeQueueTerminatedException while (true) { // get the next video to download IVideo ivideo = _workQueue.Dequeue() as IVideo; // attempt to download it Stream videoStream = SafeDownloadThumbnail(ivideo); // either get the downloaded thumbnail or if we failed due to a // timeout or other error then put in a special 'Not Available' // thumbnail image VideoThumbnail thumbnail; if (videoStream != null) { thumbnail = new VideoThumbnail(videoStream); } else { thumbnail = new NoAvailableVideoThumbnail(); } // notification that the download is completed ProcessCompletedDownload(ivideo, thumbnail); } } catch (ThreadSafeQueueTerminatedException) { } catch (Exception ex) { Trace.Fail("Unexpected exception in ThumbnailDownloader: " + ex); } }
/// <summary> /// Main worker thread logic for thumbnailer /// </summary> private void ThumbnailDownloaderMain() { try { // keep waiting for new work items until the queue is terminated // via the ThreadSafeQueueTerminatedException while (true) { // get the next video to download IVideo ivideo = _workQueue.Dequeue() as IVideo; // attempt to download it Stream videoStream = SafeDownloadThumbnail(ivideo); // either get the downloaded thumbnail or if we failed due to a // timeout or other error then put in a special 'Not Available' // thumbnail image VideoThumbnail thumbnail; if (videoStream != null) thumbnail = new VideoThumbnail(videoStream); else thumbnail = new NoAvailableVideoThumbnail(); // notification that the download is completed ProcessCompletedDownload(ivideo, thumbnail); } } catch (ThreadSafeQueueTerminatedException) { } catch (Exception ex) { Trace.Fail("Unexpected exception in ThumbnailDownloader: " + ex); } }