The Simplest Example #14
-
I feel I am missing something about the examples for the WebWorker, or something about what I am doing is wrong (which seems likely), and I would honestly love some help making use of the WebWorker. public interface IExcelService
{
public Task<IEnumerable<Change>> WebWorkAsync(IBrowserFile file);
}
public class ExcelService : IExcelService
{
public async Task<IEnumerable<Change>> WebWorkAsync(IBrowserFile file)
{
return new List<Change> { new Change("1", "2", "3")};
}
}
} In an private async Task UploadFiles2(IBrowserFile file)
{
try
{
var webWorker = await WebWorkerService.GetWebWorker();
var workerMathService = webWorker!.GetService<IExcelService>();
var result = await workerMathService.WebWorkAsync(file);
Dispatcher.Dispatch(new AddExcelListAction(result));
}
catch (Exception ex)
{
Console.WriteLine("Something went wrong: {message}", ex.Message);
}
} When my debugger hits What am I missing? I believe I added everything that needs to be added to Program.cs. ...
builder.Services.AddBlazorJSRuntime();
builder.Services.AddWebWorkerService();
builder.Services.AddSingleton<IExcelService, ExcelService>();
...
await builder.Build().BlazorJSRunAsync(); Edit: Looks like I was missing error logs - which probable explains why this is going wrong:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Off hand I would guess that your |
Beta Was this translation helpful? Give feedback.
Off hand I would guess that your
IBrowserFile file
parameter cannot be serialized or deserialized properly. Unfortunately I am out of gas for the night. I will take a closer look tomorrow. 👍