Is there any way of determening if a specific listview is visible?
We have a timer which regurarly refreshes a listview, but if another view is in focus the refresh lags the current window. Therefore I would like to write in the ViewController for the list view:
In the OnActivated method of the ListView ViewController we start the timer:
protected override void OnActivated()
{
fOppfriskTimer = new System.Timers.Timer();
fOppfriskTimer.Interval = 5 * 60 * 1000; // hvert 5te minutt
fOppfriskTimer.Elapsed += new ElapsedEventHandler(EvTimerOppfrisk);
fOppfriskTimer.Start();
base.OnActivated();
}
In the EvTimerOppfrisk event handler we do this:
private void EvTimerOppfrisk(object sender, ElapsedEventArgs e)
{
try
{
// It's here I would like to check if the ListView is in front and only run the reload if so
((Control)Frame.Template).Invoke(new ThreadStart(() => ((DevExpress.ExpressApp.ListView)View).CollectionSource.Reload()));
}
catch
{
// Ignorer feil
}
}
If I run the reload without the ((Control)Frame.Template).Invoke(new ThreadStart(() … part I get the following message:
Cross thread operation detected. To suppress this exception, set DevExpress.Data.CurrencyDataController.DisableThreadingProblemsDetection = true
I'm not sure of the consequences of setting the DisableThreadingProblemsDetection to true.
Suggestions?
Terje