Select to view content in your preferred language

Refresh Dynamic Layer using timer

3003
4
05-25-2010 04:59 AM
PieterCoetzer
Deactivated User
Hi Guys,

I'm trying to refresh a map view loaded in a WPF application, based on a timer.

I have tried to refresh the Dynamic Layers using the Layer.Refresh() on the timer's interval, but it does not refresh the map view. Only when a pan or zoom event is done on the map viewer, then the view refreshes.

My code:

Window Load:

DispatcherTimer localTimer = new DispatcherTimer();
localTimer.Tick += new EventHandler(localTimer_Tick);
localTimer.Interval = new TimeSpan(0, 0, 30);


Method to refresh the layers:

private void localTimer_Tick(object sender, EventArgs e)
{
     foreach (Layer layer in MyMap.Layers)
     if ((layer is DynamicLayer) && (layer.Visible == true))
     {
         (layer as DynamicLayer).Refresh();
     }
}


Any suggestions??
0 Kudos
4 Replies
dotMorten_esri
Esri Notable Contributor
Did you set DisableClientCache=False on the layer?
0 Kudos
PieterCoetzer
Deactivated User
Hi Morten,

I actually left it default, but with you highlighting this, I changed the property to true and whala, it refreshes.

Thanks for the guidance.

In the layer load method:

NewDynLayer.DisableClientCaching = true;
0 Kudos
dotMorten_esri
Esri Notable Contributor
Default settings are usually set for maximum performance. This means that for certain scenarios (like this) you might have to tweak the defaults.
0 Kudos
BrandonLand
Occasional Contributor
This was VERY helpful to me guys, thank you.
0 Kudos