diff --git a/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.cs b/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.cs
index ebf66164b7..2e63383030 100644
--- a/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.cs
+++ b/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.cs
@@ -1,4 +1,4 @@
-// (c) Copyright Microsoft Corporation.
+// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see https://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
@@ -165,6 +165,16 @@ namespace Avalonia.Controls
///
private bool _allowWrite;
+ ///
+ /// A boolean indicating if a cancellation was requested
+ ///
+ private bool _cancelRequested;
+
+ ///
+ /// A boolean indicating if filtering is in action
+ ///
+ private bool _filterInAction;
+
///
/// The TextBox template part.
///
@@ -1377,8 +1387,17 @@ namespace Avalonia.Controls
/// Walks through the items enumeration. Performance is not going to be
/// perfect with the current implementation.
///
- private void RefreshView()
+ private async void RefreshView()
{
+ // If we have a running filter, trigger a request first
+ if (_filterInAction)
+ {
+ _cancelRequested = true;
+ }
+
+ // Indicate that filtering is ongoing
+ _filterInAction = true;
+
if (_items == null)
{
ClearView();
@@ -1391,72 +1410,60 @@ namespace Avalonia.Controls
// Determine if any filtering mode is on
bool stringFiltering = TextFilter != null;
bool objectFiltering = FilterMode == AutoCompleteFilterMode.Custom && TextFilter == null;
-
- int view_index = 0;
- int view_count = _view!.Count;
+
List