Is there an existing issue for this?
Did you read the "Reporting a bug" section on Contributing file?
Current Behavior
The Command is NOT executed on the MainThread.
<SearchBar.Behaviors>
<toolkit:UserStoppedTypingBehavior
BindingContext="{Binding Path=BindingContext, Source={x:Reference UserStoppedTypingSearchBar}, x:DataType=SearchBar}"
Command="{Binding SearchCommand, Mode=OneTime}"
StoppedTypingTimeThreshold="750"
ShouldDismissKeyboardAutomatically="False">
</toolkit:UserStoppedTypingBehavior>
</SearchBar.Behaviors>
[RelayCommand]
private void Search(string searchTerm)
{
var mt = MainThread.IsMainThread;
Debug.WriteLine($"Search: {searchTerm} - MainThread: {mt}");
Console.WriteLine($"Search: {searchTerm} - MainThread: {mt}");
}
Expected Behavior
The Command is executed on the MainThread.
Steps To Reproduce
- Open and run solution from reproduction repository.
- Enter text in the search bar, wait for the
Command to execute and check the output in Console or Debug - MainThread: False.
Link to public reproduction project repository
https://github.com/aalsamoht/MauiUserStoppedTypingBehavior
Environment
- .NET MAUI CommunityToolkit: 11.1.0
- OS: iOS & Android
- .NET MAUI: 9.0.202
Anything else?
https://github.com/CommunityToolkit/Maui/blob/main/src/CommunityToolkit.Maui/Behaviors/UserStoppedTypingBehavior.shared.cs#L133
This causes intermittent app crashes.
Is there an existing issue for this?
Did you read the "Reporting a bug" section on Contributing file?
Current Behavior
The
Commandis NOT executed on the MainThread.Expected Behavior
The
Commandis executed on the MainThread.Steps To Reproduce
Commandto execute and check the output in Console or Debug - MainThread: False.Link to public reproduction project repository
https://github.com/aalsamoht/MauiUserStoppedTypingBehavior
Environment
Anything else?
https://github.com/CommunityToolkit/Maui/blob/main/src/CommunityToolkit.Maui/Behaviors/UserStoppedTypingBehavior.shared.cs#L133
This causes intermittent app crashes.