Skip to content

Commit cc66af9

Browse files
author
Jean-Denis Kreiss
committed
Correction synchronization
1 parent 0cbe79d commit cc66af9

3 files changed

Lines changed: 15 additions & 18 deletions

File tree

AlphaChiTech.Virtualization.Net4/PaginationManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ private Task GetCountAsync(CancellationTokenSource cts)
862862
if (!cts.IsCancellationRequested)
863863
this.RaiseCountChanged(true, _LocalCount);
864864
RemovePageRequest(Int32.MinValue);
865-
});
865+
}, TaskScheduler.FromCurrentSynchronizationContext());
866866
}
867867
else
868868
{

AlphaChiTech.Virtualization.Net4/VirtualizingObservableCollection.cs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -511,27 +511,24 @@ public bool SupressEventErrors
511511
/// <param name="args">The <see cref="NotifyCollectionChangedEventArgs"/> instance containing the event data.</param>
512512
internal void RaiseCollectionChangedEvent(NotifyCollectionChangedEventArgs args)
513513
{
514-
Application.Current.Dispatcher.Invoke(new Action(() =>
515-
{
516-
if (_BulkCount > 0) return;
514+
if (_BulkCount > 0) return;
517515

518-
var evnt = CollectionChanged;
516+
var evnt = CollectionChanged;
519517

520-
if (evnt != null)
518+
if (evnt != null)
519+
{
520+
try
521521
{
522-
try
523-
{
524-
evnt(this, args);
525-
}
526-
catch (Exception ex)
522+
evnt(this, args);
523+
}
524+
catch (Exception ex)
525+
{
526+
if (!this.SupressEventErrors)
527527
{
528-
if (!this.SupressEventErrors)
529-
{
530-
throw ex;
531-
}
528+
throw ex;
532529
}
533530
}
534-
}));
531+
}
535532
}
536533

537534
#endregion INotifyCollectionChanged Implementation
@@ -777,7 +774,7 @@ public Task ResetAsync()
777774
{
778775
var count = t.Result;
779776
this.ProviderAsync.OnReset(count);
780-
});
777+
}, TaskScheduler.FromCurrentSynchronizationContext());
781778
}
782779

783780
lock(this)

DataGridAsyncDemo/MainWindow.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public MainWindow()
5050
//we’re using Dispatcher.Invoke to give the VirtualizationManager access
5151
//to the dispatcher thread, and using a DispatcherTimer to run the background
5252
//operations the VirtualizationManager needs to run to reclaim pages and manage memory.
53-
VirtualizationManager.Instance.UIThreadExcecuteAction = a => Dispatcher.Invoke( a );
53+
VirtualizationManager.Instance.UIThreadExcecuteAction = a => Application.Current.Dispatcher.Invoke( a );
5454
new DispatcherTimer( TimeSpan.FromMilliseconds( 10 ),
5555
DispatcherPriority.Background,
5656
delegate

0 commit comments

Comments
 (0)