예제 #1
0
        void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            if (list != null)
            {
                list.Clear();
                list = null;
            }
            list       = prj.GetAreaTileList(area, zoom, 0);
            maxOfTiles = prj.GetTileMatrixMaxXY(zoom);
            all        = list.Count;

            int countOk = 0;
            int retry   = 0;

            Stuff.Shuffle <Point>(list);
            var types = GMaps.Instance.GetAllLayersOfType(type);

            for (int i = 0; i < all; i++)
            {
                if (worker.CancellationPending)
                {
                    break;
                }

                Point p = list[i];
                {
                    if (CacheTiles(ref types, zoom, p))
                    {
                        countOk++;
                        retry = 0;
                    }
                    else
                    {
                        if (++retry <= 1) // retry only one
                        {
                            i--;
                            System.Threading.Thread.Sleep(1111);
                            continue;
                        }
                        else
                        {
                            retry = 0;
                        }
                    }
                }

                worker.ReportProgress((int)((i + 1) * 100 / all), i + 1);

                System.Threading.Thread.Sleep(sleep);
            }

            e.Result = countOk;
        }
      void worker_DoWork(object sender, DoWorkEventArgs e)
      {
         if(list != null)
         {
            list.Clear();
            list = null;
         }
         list = prj.GetAreaTileList(area, zoom, 0);
         maxOfTiles = prj.GetTileMatrixMaxXY(zoom);
         all = list.Count;

         int countOk = 0;
         int retry = 0;

         Stuff.Shuffle<Point>(list);
         var types = GMaps.Instance.GetAllLayersOfType(type);

         for(int i = 0; i < all; i++)
         {
            if(worker.CancellationPending)
               break;

            Point p = list[i];
            {
               if(CacheTiles(ref types, zoom, p))
               {
                  countOk++;
                  retry = 0;
               }
               else
               {
                  if(++retry <= 1) // retry only one
                  {
                     i--;
                     System.Threading.Thread.Sleep(1111);
                     continue;
                  }
                  else
                  {
                     retry = 0;
                  }
               }
            }

            worker.ReportProgress((int) ((i+1)*100/all), i+1);

            System.Threading.Thread.Sleep(sleep);
         }

         e.Result = countOk;
      }