예제 #1
0
 private static void DownloadImage()
 {
     while (true)
     {
         ImageQueueInfo t = null;
         lock (ImageQueue.Stacks)
         {
             if (ImageQueue.Stacks.Count > 0)
             {
                 t = ImageQueue.Stacks.Dequeue();
             }
         }
         if (t != null)
         {
             Uri         uri   = new Uri(t.url);
             ImageSource image = null;
             try
             {
                 if ("file".Equals(uri.Scheme, StringComparison.CurrentCultureIgnoreCase))
                 {
                     image = Util.GetBitmapImageForBackUp(t.url);
                 }
                 if (image != null)
                 {
                     if (image.CanFreeze)
                     {
                         image.Freeze();
                     }
                     t.image.Dispatcher.BeginInvoke(new Action <ImageQueueInfo, ImageSource>((i, bmp) =>
                     {
                         if (ImageQueue.OnComplate != null)
                         {
                             ImageQueue.OnComplate(i.image, i.url, image);
                         }
                     }), new Object[] { t, image });
                 }
             }
             catch (Exception e)
             {
                 continue;
             }
         }
         if (ImageQueue.Stacks.Count > 0)
         {
             continue;
         }
         autoEvent.WaitOne();
     }
 }
예제 #2
0
 private static void OnSourceWithSourceChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
 {
     ImageQueue.Queue((Image)o, (string)e.NewValue);
 }