Skip to content

Commit f613967

Browse files
committed
Remove Platform-Specific Code
When the user didn't set an action for invoking on the main thread, the code was defaulting to a Windows implementation. The issue being: Android/iOS don't support Windows APIs.
1 parent da62a9d commit f613967

2 files changed

Lines changed: 4 additions & 20 deletions

File tree

VirtualizingCollection/VirtualizingCollection.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,4 @@
1212
<Product>AlphaChiTech.VirtualizingCollection</Product>
1313
</PropertyGroup>
1414

15-
<ItemGroup>
16-
<PackageReference Include="WindowsBase" Version="4.6.1055" />
17-
</ItemGroup>
18-
1915
</Project>

VirtualizingCollection/VirtualizingObservableCollection.cs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.Diagnostics;
77
using System.Threading;
88
using System.Threading.Tasks;
9-
using System.Windows.Threading;
109
using AlphaChiTech.Virtualization.Pageing;
1110
using AlphaChiTech.VirtualizingCollection;
1211
using AlphaChiTech.VirtualizingCollection.Interfaces;
@@ -163,9 +162,10 @@ public VirtualizingObservableCollection(
163162

164163
protected VirtualizingObservableCollection()
165164
{
166-
//To enable reset in case that noone set UiThreadExcecuteAction
165+
// If no one set the UiThreadExcecuteAction, we have to run actions on whatever thread we happen to be on.
166+
// We definitely CANNOT pull in a platform-specific implementation -- that would break other platforms...
167167
if (VirtualizationManager.Instance.UiThreadExcecuteAction == null)
168-
VirtualizationManager.Instance.UiThreadExcecuteAction = a => Dispatcher.CurrentDispatcher.Invoke(a);
168+
VirtualizationManager.Instance.UiThreadExcecuteAction = action => action();
169169
}
170170

171171
#endregion Ctors Etc
@@ -633,21 +633,9 @@ internal void RaiseCollectionChangedEvent(NotifyCollectionChangedEventArgs args)
633633
{
634634
var handler = (NotifyCollectionChangedEventHandler) @delegate;
635635

636-
// If the subscriber is a DispatcherObject and different thread.
637-
var dispatcherObject = handler.Target as DispatcherObject;
638636
try
639637
{
640-
if (dispatcherObject != null && !dispatcherObject.CheckAccess())
641-
{
642-
// Invoke handler in the target dispatcher's thread...
643-
// asynchronously for better responsiveness.
644-
dispatcherObject.Dispatcher.BeginInvoke(DispatcherPriority.DataBind, handler, this, args);
645-
}
646-
else
647-
{
648-
// Execute handler as is.
649-
handler(this, args);
650-
}
638+
handler(this, args);
651639
}
652640
catch (Exception ex
653641
) //WTF? exception catch during remove operations with collection, try add and remove investigation

0 commit comments

Comments
 (0)