I previously had this post: thinkgeo.com/forums/MapSuite/tabid/143/aft/11927/Default.aspx.
Our project has expanded and I have added more overlays to it that get refreshed more and more. However, as that post explains, the ‘Feature Source is not Open’ exception happens when the overlay gets refreshed while it is refreshing (if I understood that correctly).
My question is if there is some check built into the system that allows me to check if a layer is refreshing before calling a refresh. I have been trying to use the overlay drawing and overlay drawn events on my largest layer to prevent refreshing, but I have more overlays that are still causing the occasionally issue.
I am looking to avoid adding handlers to every overlay for drawing and drawn events as checks. This seems like it is mostly a matter of timing for the random crashes.
To further explain… I have an InMemoryFeatureLayer and associated LayerOverlay that receives information from a GPS unit and refreshes a single point on the screen approximately every second as new location information comes in. I then have numerous other overlays that represent my tiled basemap layers, a Google Maps basemap, and a couple more InMemoryFeatureLayers doing other things. The issue seems to come when the map gets a full-refresh when the extent changes and the GPS Overlay is still updating. However, like I said, it seems to be a matter of timing since it doesn’t always happen.
Basically, I am looking for a way to check when things are refreshing without adding all the handlers. Also, if there is another reason to have the exception outlined in the forum link, I would like to have more information on it. We were field testing this software with the GPS unit, and this problem kept creeping up on us.
Thanks in advance!
How to check if layer is refreshing
Hi Brandon,
I think we don’t have a function to make sure whether a layer is refreshing.
If the problem is just like what you think, that two thread refresh same layer, one from GPS unit and one from whole refresh. Do you think refresh other overlays exception GPS overlay instead of refresh all is a solution?
I think you can build a single refresh function, here you loop all overlay and refresh them but not GPS overlay.
Regards,
Don
Hi Brandon,
I didn’t figure out a good way to check if a layer is rendering, but we are rendering the map based on the layeroverlay, So, I guess if checking whether a layerovelay is drawing should also be fit for your need. There are two ways to estimate a layeroverlay is refreshing.
Dim
staticOverlay
As
New
LayerOverlay()
staticOverlay.Layers.Add(
“WorldLayer”
, worldLayer)
'staticOverlay.TileType = TileType.SingleTile;
staticOverlay.Drawn +=
New
System.EventHandler(Of DrawnOverlayEventArgs)(
AddressOf
staticOverlay_Drawn)
staticOverlay.DrawTilesProgressChanged +=
New
System.EventHandler(Of DrawTilesProgressChangedTileOverlayEventArgs)(
AddressOf
staticOverlay_DrawTilesProgressChanged)
wpfMap1.Overlays.Add(staticOverlay)
wpfMap1.CurrentExtent =
New
RectangleShape(-133.2515625, 89.2484375, 126.9046875, -88.290625)
wpfMap1.Refresh()
End
Sub
Private
Sub
staticOverlay_DrawTilesProgressChanged(sender
As
Object
, e
As
DrawTilesProgressChangedTileOverlayEventArgs)
If
e.ProgressPercentage = 100
Then
MessageBox.Show(
“current layeroverlay is finished”
)
End
If
End
Sub
Private
Sub
staticOverlay_Drawn(sender
As
Object
, e
As
DrawnOverlayEventArgs)
MessageBox.Show(
“current layeroverlay is finished”
)
End
Sub
Please let me know if any questions.
Thanks.
Troy
Thanks for the information. I have been using my Google Maps basemap’s drawing and drawn events to disable updating/refreshing on my GPS layer. I was hoping there was a way to bypass attaching handlers to all my overlays to monitor them. Like I stated in my other post though, I will probably not attach handlers, but just use a global unhandled exception catcher and mark these issues as handled.
Hi Brandon,
In fact I am thinking about one thing, why not create a standalone function which refresh all overlay but not refresh your GPS overlay?
Follow this way, your GPS overlay will only refresh when location update and other overlays will refresh when you call refresh function.
Regards,
Don