# ✅ Fix Applicato: Errore Dispatcher Login/Logout ## 🐛 Problema Errore intermittente durante login/logout: ``` System.InvalidOperationException: 'The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher...' ``` ## ✅ Soluzione Modificato `App.razor` per usare `InvokeAsync()` per aggiornamenti UI thread-safe. ## 📝 Codice Modificato ### PRIMA (❌ Non Thread-Safe) ```csharp protected override void OnInitialized() { AuthService.OnAuthenticationStateChanged += StateHasChanged; // ❌ } ``` ### DOPO (✅ Thread-Safe) ```csharp protected override void OnInitialized() { AuthService.OnAuthenticationStateChanged += OnAuthenticationStateChanged; // ✅ } private void OnAuthenticationStateChanged() { InvokeAsync(StateHasChanged); // ✅ Thread-safe } ``` ## 🎯 Risultato - ✅ Nessun errore durante login - ✅ Nessun errore durante logout - ✅ Aggiornamenti UI fluidi e thread-safe - ✅ Comportamento stabile e prevedibile ## 📁 File Modificato - `Data_Coupler\App.razor` ## 📚 Documentazione - Dettagli completi: `FIX_LOGIN_DISPATCHER_ERROR.md` - Documentazione aggiornata: `SISTEMA_LOGIN.md` --- **Status**: ✅ RISOLTO **Data**: 8 Ottobre 2025