Improve mechanism to start Blazor in windows apps (#9961)#9962
Improve mechanism to start Blazor in windows apps (#9961)#9962yasmoradi merged 1 commit intobitfoundation:developfrom yasmoradi:9961
Conversation
WalkthroughThe changes modify the Blazor application startup logic in two separate Changes
Sequence Diagram(s)sequenceDiagram
participant P as Program
participant BWV as BlazorWebView
participant BA as Blazor Application
P->>BWV: Invoke StartBlazor(blazorWebView)
loop Polling Loop until startup succeeds
BWV->>BA: Execute "Blazor.start()"
BA-->>BWV: Return result (null or non-null)
end
BWV->>P: Signal Blazor Started Successfully
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Windows/Program.cs (1)
127-133: Consider extracting StartBlazor to a shared utility class.The StartBlazor method is duplicated between the Demo and Boilerplate templates. Consider moving it to a shared utility class to maintain consistency and reduce duplication.
Create a new shared utility class:
public static class BlazorStartupUtils { public static async Task StartBlazor(BlazorWebView blazorWebView, Action<Exception>? onError = null) { using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30)); try { while (!cts.Token.IsCancellationRequested && await blazorWebView.WebView.ExecuteScriptAsync("Blazor.start()") is "null") { await Task.Yield(); } if (cts.Token.IsCancellationRequested) { throw new TimeoutException("Blazor failed to start within the timeout period."); } } catch (Exception ex) { onError?.Invoke(ex); throw; } } }Also applies to: 114-120
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Windows/Program.cs(1 hunks)src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Windows/Program.cs(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build and test
🔇 Additional comments (2)
src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Windows/Program.cs (2)
127-133: Apply the same timeout mechanism as in the Demo client.This implementation has the same potential issue with infinite polling as identified in the Demo client's Program.cs.
Please apply the same timeout and error handling improvements suggested for the Demo client.
119-119: Apply the same error handling as in the Demo client.This implementation has the same fire-and-forget issue as identified in the Demo client's Program.cs.
Please apply the same error handling improvements suggested for the Demo client.
closes #9961
Summary by CodeRabbit