Created
April 12, 2016 15:26
-
-
Save luetm/3d3c329f7c2b3d4e0fa6cff26c2cb3a2 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 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