Interactable UI During Exporting in Blazor WebAssembly #58836
Labels
area-blazor
Includes: Blazor, Razor Components
Needs: Author Feedback
The author of this issue needs to respond in order for us to continue investigating this issue.
Status: No Recent Activity
Describe the bug
Subject: Request for Enhancement: Interactable UI During Exporting in Blazor WebAssembly
Description:
We are encountering a significant challenge with UI interaction in Blazor WebAssembly when performing data exports. Our application handles large datasets (e.g., 10,000 records), and during export operations, the entire web page becomes unresponsive, preventing any further user interaction until the export completes.
In Blazor Server, we have successfully maintained UI responsiveness by utilizing multi-threading with Task.Run, as shown below:
Before:
`csharp
await ExportHelper(GridModel, DataSource);
using MemoryStream outputStream = new MemoryStream();
_workbook.Save(outputStream, IsCsvExport);
`
After:
`csharp
await Task.Run(() => ExportHelper(GridModel, DataSource)).ConfigureAwait(false);
using MemoryStream outputStream = new MemoryStream();
await Task.Run(() => _workbook.Save(outputStream, IsCsvExport)).ConfigureAwait(false);`
While this approach works effectively in Blazor Server, it does not yield the same results in Blazor WebAssembly. The single-threaded nature of WebAssembly causes the export operation to block the UI thread, rendering the page unresponsive.
We have attempted to split the data source and apply Task.Yield in WebAssembly to enhance responsiveness, but these efforts have not been successful.
Expected Behavior
We aim to achieve similar UI responsiveness in Blazor WebAssembly as we experience in Blazor Server, allowing users to interact with the page during export operations.
Request:
We kindly request consideration for adding support for responsive, non-blocking long-running tasks (e.g., data exports) in Blazor WebAssembly. This enhancement would enable us to maintain an interactive UI for end-users.
Environment Details:
Device: DELL Latitude 3410
Browser: Chrome
Blazor WebAssembly Version: 8.0.0
.NET Version
Blazor WebAssembly Version: 8.0.0
The text was updated successfully, but these errors were encountered: