Пример #1
0
 public WebImage(List<WebImageSearchItem> searchItems, int maxImageResults, ImageRecievedCallaback callback)
 {
     _searchItems = searchItems;
     _maxImageResults = maxImageResults;
     _callback = callback;
     _processedImagesCount = 0;
 }
Пример #2
0
 public WebImage(string searchText, int maxImageResults, ImageRecievedCallaback callback)
     : this(new List<WebImageSearchItem>(new WebImageSearchItem[]{ new WebImageSearchItem(searchText)}), maxImageResults, callback)
 {
 }
Пример #3
0
 public WebImage(List<WebImageSearchItem> searchItems, ImageRecievedCallaback callback)
     : this(searchItems, 1, callback)
 {
 }
Пример #4
0
 /// <summary>
 /// Process a batch of searchTerms and calls the callback whenever an image is downloaded. With this many image request are sent at the same time.        
 /// </summary>
 /// <param name="searchTerms">The list of terms to search for</param>
 /// <param name="callback">The method to call when the image has been downloaded</param>
 /// <param name="maxThreadCount">The amount of image requests that can run at the same time</param>
 /// <returns></returns>
 public static WebImageThreadManager ProcessImageBatchWithThreadPool(List<WebImageSearchItem> searchItems, int maxImages, ImageRecievedCallaback callback, int maxThreadCount)
 {
     WebImage wi = new WebImage(searchItems, maxImages, callback);
     return new WebImageThreadManager(wi.StartProcessImageBatchWithThreadPool(maxThreadCount));
 }
Пример #5
0
        /// <summary>
        /// Process a batch of searchTerms and calls the callback whenever an image is downloaded. With this only one thread is started.
        /// </summary>
        /// <param name="searchTerms">The list of terms to search for</param>
        /// <param name="callback">The method to call when the image has been downloaded</param>
        /// <returns>The running Thread</returns>
        public static WebImageThreadManager ProcessImageBatchBySingleThread(List<WebImageSearchItem> searchItems, ImageRecievedCallaback callback)
        {
            WebImage wi = new WebImage(searchItems, callback);
            Thread t = new Thread(new ThreadStart(wi.threadStartForProcessImageBatchBySingleThread));
            t.Start();

            return new WebImageThreadManager(t);
        }
Пример #6
0
        /// <summary>
        /// Fetches images from the web for a search term.
        /// </summary>
        /// <param name="searchTerm"></param>
        /// <param name="maxImages"></param>
        /// <param name="callback"></param>
        /// <returns></returns>
        public static WebImageThreadManager GetImagesWithSingleThread(string searchTerm, int maxImages, ImageRecievedCallaback callback)
        {
            WebImage wi = new WebImage(searchTerm, maxImages, callback);
            Thread t = new Thread(new ThreadStart(wi.threadStartForProcessImageBatchBySingleThread));
            t.Start();

            return new WebImageThreadManager(t);
        }