Offline mode

Apr 23, 2010 at 2:52 PM

Hi, the "caching" seem to work well, but when I use serverandcache mode, if I loose my internet connection, the object doesn't use the cache, it put "empty" tile.

 

At the same time, it is possible for be able to "drag" the map even if we don't have a title?

Coordinator
Apr 24, 2010 at 12:38 PM

not in wpf version

Apr 24, 2010 at 6:24 PM

you mean we can't drag the map in wpf or in wpf is not using the cache when I loose internet connection?

 

Coordinator
Apr 24, 2010 at 6:28 PM

serverandcache == look in cache return if found, else look in servers. And it doesn't matter which version ;}

Apr 24, 2010 at 6:30 PM

hmm, okay, I'll debug because when I disconnect my internet cable and if I "move" the map I don't have any tile appearing.

 

for the "caching" I just need to set the serverandcache mode, correct?

Coordinator
Apr 24, 2010 at 6:37 PM
Edited Apr 24, 2010 at 6:37 PM

it's default option, works just perfectly

Apr 24, 2010 at 7:45 PM
Edited Apr 24, 2010 at 7:51 PM

hmm not for me, maybe I don't have the last version, I just realise the HG repositoty is not updated with your source code. the last update on it it's 2 weeks old. Are you updating the HG frequency, or it's better to re-download the full code each time?

 

edit:

Forget that, I just delete en re-clone the repository and working fine now

Coordinator
Apr 24, 2010 at 7:51 PM

perfect!

Apr 24, 2010 at 8:20 PM

Okay, just found my "Error", you're right it use cache and never go on the server if it have it... but if we are not connected and I try to move on the map, it will try to connect to the server, so there it waiting for the server, if I go back where I have the map, it's working, but if I repeat that 5-6 time, it's not working anymore, I presume you have a max number of queue and when that happen, even if it's on the cache, it will wait ...

 

here is my immediate windows:

Starting GetResponse: {X=74751,Y=41653}
Starting GetResponse: {X=74751,Y=41652}
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:08.3780000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:08.7320000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:09.6740000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:09.7370000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:10.0570000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:10.1530000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:10.6260000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:10.6810000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:11.0410000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:11.0980000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:11.8730000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:12.2250000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:12.3290000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:12.6730000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:13.0330000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:13.3850000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:13.4570000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:13.7930000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:13.8180000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:13.8570000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:14.2020000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:14.2410000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:14.2740000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:14.6010000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:14.9450000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:15.0340000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:16.0970000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:16.2090000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:16.9130000
OnTileLoadStart: 35 tiles to load at zoom 16, time: 15:14:17.3610000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:22.1930000

[Waiting Here]

A first chance exception of type 'System.Net.WebException' occurred in System.dll A first chance exception of type 'System.Net.WebException' occurred in System.dll A first chance exception of type 'System.Net.WebException' occurred in System.dll A first chance exception of type 'System.Net.WebException' occurred in System.dll A first chance exception of type 'System.Net.WebException' occurred in System.dll GetImageFrom: System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 67.18.252.221:8118 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) --- End of inner exception stack trace --- at System.Net.HttpWebRequest.GetResponse() at GMap.NET.GMaps.GetImageFrom(MapType type, Point pos, Int32 zoom) in C:\Dev\CodePlex\greatmaps\GMap.NET.Core\GMap.NET\GMaps.cs:line 2214 GetImageFrom: System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 67.18.252.221:8118 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) --- End of inner exception stack trace --- at System.Net.HttpWebRequest.GetResponse() at GMap.NET.GMaps.GetImageFrom(MapType type, Point pos, Int32 zoom) in C:\Dev\CodePlex\greatmaps\GMap.NET.Core\GMap.NET\GMaps.cs:line 2214 GetImageFrom: System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 67.18.252.221:8118 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) --- End of inner exception stack trace --- at System.Net.HttpWebRequest.GetResponse() at GMap.NET.GMaps.GetImageFrom(MapType type, Point pos, Int32 zoom) in C:\Dev\CodePlex\greatmaps\GMap.NET.Core\GMap.NET\GMaps.cs:line 2214 GetImageFrom: System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 67.18.252.221:8118 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) --- End of inner exception stack trace --- at System.Net.HttpWebRequest.GetResponse() at GMap.NET.GMaps.GetImageFrom(MapType type, Point pos, Int32 zoom) in C:\Dev\CodePlex\greatmaps\GMap.NET.Core\GMap.NET\GMaps.cs:line 2214 GetImageFrom: System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 67.18.252.221:8118 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) --- End of inner exception stack trace --- at System.Net.HttpWebRequest.GetResponse() at GMap.NET.GMaps.GetImageFrom(MapType type, Point pos, Int32 zoom) in C:\Dev\CodePlex\greatmaps\GMap.NET.Core\GMap.NET\GMaps.cs:line 2214 ProcessLoadTask: 17 - {X=74751,Y=41653} -> empty tile, retry 0 ProcessLoadTask: 17 - {X=74751,Y=41651} -> empty tile, retry 0 ProcessLoadTask: 17 - {X=74751,Y=41654} -> empty tile, retry 0 ProcessLoadTask: 17 - {X=74751,Y=41655} -> empty tile, retry 0 ProcessLoadTask: 17 - {X=74751,Y=41652} -> empty tile, retry 0 Starting GetResponse: {X=74751,Y=41651} Starting GetResponse: {X=74751,Y=41654} Starting GetResponse: {X=74751,Y=41655} Starting GetResponse: {X=74751,Y=41653} Starting GetResponse: {X=74751,Y=41652}

OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:08.3780000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:08.7320000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:09.6740000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:09.7370000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:10.0570000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:10.1530000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:10.6260000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:10.6810000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:11.0410000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:11.0980000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:11.8730000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:12.2250000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:12.3290000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:12.6730000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:13.0330000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:13.3850000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:13.4570000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:13.7930000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:13.8180000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:13.8570000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:14.2020000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:14.2410000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:14.2740000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:14.6010000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:14.9450000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:15.0340000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:16.0970000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:16.2090000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:16.9130000
OnTileLoadStart: 35 tiles to load at zoom 16, time: 15:14:17.3610000
OnTileLoadStart: 35 tiles to load at zoom 17, time: 15:14:22.1930000
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
GetImageFrom: System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 67.18.252.221:8118
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.GetResponse()
   at GMap.NET.GMaps.GetImageFrom(MapType type, Point pos, Int32 zoom) in C:\Dev\CodePlex\greatmaps\GMap.NET.Core\GMap.NET\GMaps.cs:line 2214
GetImageFrom: System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 67.18.252.221:8118
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.GetResponse()
   at GMap.NET.GMaps.GetImageFrom(MapType type, Point pos, Int32 zoom) in C:\Dev\CodePlex\greatmaps\GMap.NET.Core\GMap.NET\GMaps.cs:line 2214
GetImageFrom: System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 67.18.252.221:8118
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.GetResponse()
   at GMap.NET.GMaps.GetImageFrom(MapType type, Point pos, Int32 zoom) in C:\Dev\CodePlex\greatmaps\GMap.NET.Core\GMap.NET\GMaps.cs:line 2214
GetImageFrom: System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 67.18.252.221:8118
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.GetResponse()
   at GMap.NET.GMaps.GetImageFrom(MapType type, Point pos, Int32 zoom) in C:\Dev\CodePlex\greatmaps\GMap.NET.Core\GMap.NET\GMaps.cs:line 2214
GetImageFrom: System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 67.18.252.221:8118
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.GetResponse()
   at GMap.NET.GMaps.GetImageFrom(MapType type, Point pos, Int32 zoom) in C:\Dev\CodePlex\greatmaps\GMap.NET.Core\GMap.NET\GMaps.cs:line 2214
ProcessLoadTask: 17 - {X=74751,Y=41653} -> empty tile, retry 0
ProcessLoadTask: 17 - {X=74751,Y=41651} -> empty tile, retry 0
ProcessLoadTask: 17 - {X=74751,Y=41654} -> empty tile, retry 0
ProcessLoadTask: 17 - {X=74751,Y=41655} -> empty tile, retry 0
ProcessLoadTask: 17 - {X=74751,Y=41652} -> empty tile, retry 0
Starting GetResponse: {X=74751,Y=41651}
Starting GetResponse: {X=74751,Y=41654}
Starting GetResponse: {X=74751,Y=41655}
Starting GetResponse: {X=74751,Y=41653}
Starting GetResponse: {X=74751,Y=41652}
Coordinator
Apr 24, 2010 at 8:26 PM

loading is limited by 5 tiles in one moment, so if do not have them, and server is not reachable, you have nothing ;]

Apr 24, 2010 at 8:44 PM

yeah, I understand that point :) but since i'm using a usb data edge card, I loose the connection to internet some time.. and right now the problem I have is I have empty tile after some time... and the reason is when I don't have the internet connection the application hang.

 

So I have 5 connection trying to "download" new map because I don't have them, fine. But if I come back when I have the map in cache, it will not load them, because the application we'll wait for the 5 connection finish first... so it take 1-2 min for the timeout, and I don't have any map on screen even if I have those. (maybe it will be a great idea to check if I have the title into memory map?)

 

and after some time, even if I have the internet connection back, it "loading" for ever. I need to stop the "demo" and play it again for make it work again.

 

maybe a solution will be, if we have 5 and more "waiting" connection, maybe make another connection, but only for checking cache?

Sorry for bad english, i'm french :)

 

Coordinator
Apr 24, 2010 at 8:54 PM

you can decrease time-out value, to 10s or so, and also there is retry included, you can set it to 0 ;}

MainMap.Manager.Timeout = 5 * 1000; // 5s
MainMap.Manager.RetryLoadTile = 0; // disable retry

Apr 24, 2010 at 8:58 PM

yeah, just saw that, I didn't finish to check the code, but I think when the "task" cannot load the map, even with a retryload of 0 it will not remove the task, so if I go back later, to try to load the same "tile" even if I have a good internet connection now, it will not try to reload it because we still have this "zombie" task. so theif(!tileLoadQueue.Contains(task)) into the UpdateBound will be "true" ...

Coordinator
Apr 24, 2010 at 9:04 PM

each task do: task = tileLoadQueue.Dequeue();

so of you hit refresh it starts loading the same tiles again

Coordinator
Apr 24, 2010 at 9:04 PM

..and it works pretty good even on my mobile

Apr 24, 2010 at 9:08 PM

yeah, it was a guest, I'll go over the code and see why, but I uncomment the line Debug.WriteLine("TileLoadQueue: " + tileLoadQueue.Count);

and when that happen the tileLoadQueue.Count stay near 131 and even if internet is back, it stay at 131. My new "thinking" (because you just put my old in garbage :) ) it's when we got an error from the web it doesn't go through a new tileLoadQueue, maybe something "block" it... you can easly reproduce that by disable your internet connection... each time I do it it doing that...

 

Apr 24, 2010 at 9:11 PM

oh, maybe I should start another discution for that, but maybe it will be a good idea to replace all the debug.print by an event? in my case, so I'll be able to put the "Result" into a visible textbox (or whatever) for remote debuging ?

Coordinator
Apr 24, 2010 at 9:18 PM

debug prints are just for debug, in release build they are removed

Coordinator
Apr 24, 2010 at 9:23 PM
Edited Apr 24, 2010 at 9:40 PM

you can check for Internet connection on application startup and if there is none, set mode to CacheOnly

try
{
  System.Net.IPHostEntry e = System.Net.Dns.GetHostByName("www.google.com");
}
catch // host not reachable. 
{
  MainMap.Manager.Mode = AccessMode.CacheOnly;
}

Apr 24, 2010 at 9:50 PM

sure, but the problem is not that, it's when I loose internet, and that can happen during a middle of a query, so that will not work... let me try to find a solution to the code and I'll post it here :)

 

Coordinator
Apr 24, 2010 at 9:54 PM

go ahead! ;}

Apr 24, 2010 at 10:36 PM

okay, I think I found the problem.

 

when we "load" a map, in my case, it load 35 tile, so it will launch 35 time the function with: 

if(loaderLimit.WaitOne(GMaps.Instance.Timeout, false))

but, since the server doesn't response in time, all other thread who are waiting, timeout, without removing a "Task", so that why I still have those task without any thread to do it. And since this task is there it will never try to "reload" it because of the if(!tileLoadQueue.Contains(task))

 

 

Coordinator
Apr 24, 2010 at 10:40 PM

solution?

Apr 24, 2010 at 10:44 PM

Hmm, one easy solutino will be to remove the "timeout" or put a really really long timeout... but i'm not sure if it's okay.. since the application can start many many many thread...

 

or maybe another approach. since i'm not a very good programmor :) maybe it stupid, but, why not start 5 thread at start, trying to "Execute" queue from Task ?

 

Coordinator
Apr 24, 2010 at 11:13 PM

and maybe solution is to get good Internet connection or precache the map ;}

Apr 24, 2010 at 11:17 PM

since it's outdoor application I don't have the control of the internet :)

and even with precache the map... it can do the same thing...

at the end, with the current code, if something happen in the middle of this function and take more of 30 sec, you'll have this issue.. not only from the internet connection.. it can be a really slow hard disk reading (for the sqlite by exemple)... and because of that, all the application stop working

 

I replace the if(loaderLimit.WaitOne(GMaps.Instance.Timeout, false))

by

if(loaderLimit.WaitOne()) and it's working well now...

 

 

Apr 24, 2010 at 11:24 PM

Hmm, i'm looking at the code right now, I presume you put the maximum of 5 thread at the same time, for don't send 50 web query at the same time at google or openstreetmap? if yes, why not put theloaderLimit before the line

using(HttpWebResponse response = request.GetResponse() as HttpWebResponse)

in GetImageFrom, so if we have the image in cache, it will load the 50 images at the same time.. and you'll not "overload" theirs website

 

Coordinator
Apr 24, 2010 at 11:30 PM
Edited Apr 24, 2010 at 11:40 PM

slow hdd ;}

..anyway good point, needs few tests to make it work

Apr 24, 2010 at 11:37 PM

do not laugh, but my incar computer have a really slow hhd :)

 

I move all the loaderLimit into the GetImageFrom, add a thread.sleep into the catch of the webresult

                  //if (loaderLimit.WaitOne(GMaps.Instance.Timeout, false))
                  if (loaderLimit.WaitOne())
                  {

                      Debug.WriteLine("Starting GetResponse: " + pos);

                      using(HttpWebResponse response = request.GetResponse() as HttpWebResponse)

                       ...

                  }
                  loaderLimit.Release();
               }
            }
         }
         catch(Exception ex)
         {
            ret = null;
            Debug.WriteLine("GetImageFrom: " + ex.ToString());
            Thread.Sleep(1111);
         }

and I remove the thread.sleep from the ProcessLoadTask, since it's done before now

                              Debug.WriteLine("ProcessLoadTask: " + task + " -> empty tile, retry " + retry);
                              {
                                  //Thread.Sleep(1111);
                              }

 

running very good now, and very fast, I'm suggesting the change :)

 

 

Coordinator
Apr 24, 2010 at 11:42 PM

hm... what if you put that before limiter?

 

void ProcessLoadTask(object obj)
      {
         bool last = false;

         LoadTask? task = null;

         lock(tileLoadQueue)
         {
            if(tileLoadQueue.Count > 0)
            {
               task = tileLoadQueue.Dequeue();
               {
                  last = tileLoadQueue.Count == 0;
                  //Debug.WriteLine("TileLoadQueue: " + tileLoadQueue.Count);
               }
            }
         }

         if(loaderLimit.WaitOne(GMaps.Instance.Timeout, false))
         {
            if(task.HasValue)
            { .....

 

Apr 24, 2010 at 11:47 PM

hmm good point :)

 

that will work too, you still have the "sleep" slowing down a little, but at least it's fixing my problem :)

Coordinator
Apr 24, 2010 at 11:56 PM

...maybe this do? If you set retry to zero it doesn't sleep:

 

else if(GMaps.Instance.RetryLoadTile > 0)
{
   Debug.WriteLine("ProcessLoadTask: " + task + " -> empty tile, retry " + retry);
   {
      Thread.Sleep(1111);
   }
}

 

Apr 24, 2010 at 11:58 PM

yup, that will work, I was removing it because I suppose you was sleeping for lets the webservice "answering", in the code I suggest, it was sleeping only with it was using the web... because I don't think you need to sleep if you receive a null from local database?

Coordinator
Apr 25, 2010 at 12:07 AM

you see, if you get null from local database, then automatically you get tile from second level cache and if still nothing you finally use web, and if you still get zero, engine retries the same process again, and that is why i use some sleep before retry. So you can't really know from where you get the data ;}

Apr 25, 2010 at 12:09 AM

oh, okay, I understand, since i'm not using the second cache, I didn't see this code :)

 

Coordinator
Apr 25, 2010 at 12:26 AM

actually i've missed to tell about memory cache in the first place ;} anyway changes are already committed

Apr 25, 2010 at 12:27 AM

nice :)

 

thank you

Coordinator
Apr 25, 2010 at 12:41 AM

thanks You ;}