AsyncRelayCommand IsRunning only true on return of Task
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
Inizia individuando l'implementazione di AsyncRelayCommand e traccia come vengono assegnati ExecutionTask e IsRunning durante l'invocazione del delegato asincrono. Riproduci il problema con la parte sincrona di Execute, quindi verifica che lo stato del comando venga aggiornato prima dell'esecuzione del corpo del delegato e rimanga corretto durante l'esecuzione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
The ExecutionTask and IsRunning of the AsyncRelayCommand is only set after the execute returns a Task, so on the first real async function.
As long as it's running synchronously, the ExecutionTask is still the previous task and IsRunning is based on that one
Regression
No response
Steps to reproduce
- Create an AsyncRelayCommand with an async function that returns a Task
relayCommand = AsyncRelayCommand(Execute);
- Check if is IsRunning in the synchronous part of the execution method
async Task Execute()
{
Debug.Assert(relayCommand.IsRunnung); // Fails
Debug.Assert(relayCommand.AsyncRelayCommand == null); // at least not be the previous task?
await Task.Wait(1000);
}
Expected behavior
That AsyncRelayCommand is set to null and IsRunning is true before the execute method is called.
Screenshots
No response
IDE and version
VS 2022
IDE version
No response
Nuget packages
- CommunityToolkit.Common
- CommunityToolkit.Diagnostics
- CommunityToolkit.HighPerformance
- CommunityToolkit.Mvvm (aka MVVM Toolkit)
Nuget package version(s)
8.2.0
Additional context
Ideally, you'd not call the IsRunning inside the Execute call, but I've done it by accident already that I run setup that I wanted to skip when a command is running, that is called from the Execute function before any network calls.
Workaround is just doing
await Task.Yield();
as the first line in the Execute method.
Help us help you
Yes, I'd like to be assigned to work on this item
- Lingua principale
- C#
- Stelle
- 3.8k
- Fork
- 401
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di CommunityToolkit/dotnet
-
bug :bug:
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
CommunityToolkit/dotnet#1206 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
CommunityToolkit/dotnet#1186 ·
-
bug :bug:
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 68/100
CommunityToolkit/dotnet#648 ·
-
bug :bug:
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
CommunityToolkit/dotnet#1215 ·
-
feature request :mailbox_with_mail:
Difficoltà 5/5 Più di una settimana Idoneità per principianti 45/100
CommunityToolkit/dotnet#1214 ·
Tutte le issue di CommunityToolkit/dotnet
Issue simili
-
:watch: Not Triaged dotnet-target-version
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
copilot documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 2 giorni
-
untriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
dotnet/dotnet-api-docs#13124 ·
I maintainer di solito rispondono entro 1 giorno
-
agentic-workflows
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
type:bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
BHoM/MidasCivil_Toolkit#441 ·