I’m working on a high performance BlackJack program. The application is mostly for show but there are some times when I want to disable all interface updates for performance reasons. When I update the UI (automatically with 100% bindings) I can get ~600 Cards/Sec dealt, without the table and controls being updated I can get 22,000+ Cards/Sec dealt.
I’m toying with simple ways to disable UI updates. The only way I’ve found is to set my BlackJackTable UserControls’s DataContext to that of a blank table ViewModel and allow the real table ViewModel to do all the computations. This poses problems when setting the DataContexts back to the real table ViewModel if I want to watch whats going on again.
So, in summary… Is there a simple way to suspend all bindings on an object? Removing visibility and disabled (IsEnabled = false) doesn’t help performance. Any suggestions for doing this the right way?
You don’t NEED to read below, but if you’re curious (or have a solution), here’s what I’ve been doing:
private void FastModeChk_Checked(object sender, RoutedEventArgs e) {
if (TableViewModel.GameStatisticsVM.CardsDealt > 0) {
BlackJackTable.DataContext = BlankTVM;
DealerControlsTabItem.DataContext = BlankTVM;
PlayerControlsTabItem.DataContext = BlankTVM.CurrentPlayerHandVM;
DebugLogTabItem.DataContext = BlankTVM.LoggingVM;
}
}
private void FastModeChk_Unchecked(object sender, RoutedEventArgs e) {
BlackJackTable.DataContext = TableViewModel;
DealerControlsTabItem.DataContext = TableViewModel;
PlayerControlsTabItem.DataContext = TableViewModel.CurrentPlayerHandVM;
DebugLogTabItem.DataContext = TableViewModel.LoggingVM;
}
The PlayerControlsTabItem doesn’t keep pulling from CurrentPlayerHandVM. I’m calling OnPropertyChanged and everything works great if the box doesn’t get checked. This code doesn’t work for some reason.
My thought is to put a short circuit in the
RaisePropertyChanged()method call so that thePropertyChangedevent is not called.something like: