I have a TimeBar in sync with the zoom/pan of multiple ChartViews. I have code that successfully converts between the time ranges of the TimeBar and the Pan/Zoom properties of the ChartViews, and all works well until I try to sync between a TimeBar and multiple ChartViews.
The execution logic goes like this:
Change the TimeBar
TimeBar change event is fired, ChartViews are updated.
ChartView pan/zoom change events are fired. TimeBar is updated, other ChartViews are updated.
TimeBar and ChartView change events are fired. TimeBar is updated, other ChartViews are updated...
etc.
... and so the application hangs from infinite event recursion. The common approach to prevent this is using a bool as a flag to prevent further execution, but this doesn't work. It seems like the assignment of the pan/zoom properties of ChartView objects are delegated through i.e. Dispatcher.BeginInvoke, since the sub-events aren't fired in-between the times where the recursion flag is set.
My current idea is to set the flag to true and set a timer i.e. 100ms later to reset the flag to false, but I'd like to know if there's a less hacky way to do this?
The execution logic goes like this:
Change the TimeBar
TimeBar change event is fired, ChartViews are updated.
ChartView pan/zoom change events are fired. TimeBar is updated, other ChartViews are updated.
TimeBar and ChartView change events are fired. TimeBar is updated, other ChartViews are updated...
etc.
... and so the application hangs from infinite event recursion. The common approach to prevent this is using a bool as a flag to prevent further execution, but this doesn't work. It seems like the assignment of the pan/zoom properties of ChartView objects are delegated through i.e. Dispatcher.BeginInvoke, since the sub-events aren't fired in-between the times where the recursion flag is set.
My current idea is to set the flag to true and set a timer i.e. 100ms later to reset the flag to false, but I'd like to know if there's a less hacky way to do this?