Skip to content

Commit 4d41a68

Browse files
committed
Minor improve for rendering delay.
1 parent e82a01e commit 4d41a68

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

samples/BlazorChat/Pages/ChatRoom.razor

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ else
8181

8282
try
8383
{
84+
// Start chatting and force refresh UI, ref: https://github.com/dotnet/aspnetcore/issues/22159
85+
_isChatting = true;
86+
await Task.Delay(1);
87+
8488
// remove old messages if any
8589
_messages.Clear();
8690

@@ -97,13 +101,12 @@ else
97101

98102
await _hubConnection.StartAsync();
99103

100-
_isChatting = true;
101-
102104
await SendAsync($"[Notice] {_username} joined chat room.");
103105
}
104106
catch (Exception e)
105107
{
106108
_message = $"ERROR: Failed to start chat client: {e.Message}";
109+
_isChatting = false;
107110
}
108111
}
109112

0 commit comments

Comments
 (0)