Created
April 12, 2016 15:24
-
-
Save luetm/137374dd47ee247c9a7bd92f69364d51 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ObservableCollection<IInvoicePosition> Positions // << dependency property | |
{ | |
get { /* ... */ } | |
set { /* ... */ } | |
} | |
private volatile int _queue; | |
private readonly object _queueLock = new object(); | |
private async void OnItemsSourceChanged(object sender, NotifyCollectionChangedEventArgs e) | |
{ | |
lock (_queueLock) | |
{ | |
_queue++; | |
} | |
// I use a await instead of Thread.Sleep() to avoid blocking the UI thread | |
// This might be the crux, any better way? | |
await Task.Delay(100); | |
lock (_queueLock) | |
{ | |
_queue--; | |
} | |
if (_queue > 0) return; | |
Draw(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment