Code Monkey home page Code Monkey logo

blazorworker's People

Contributors

dependabot[bot] avatar joelverhagen avatar matheos96 avatar petertorocsik avatar teo-tsirpanis avatar tewr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blazorworker's Issues

BlazorWorker does not work in net6 with published release

Hello,
it seems that BlazorWorker does not support net6 publishing.

For example, if you create a project with the standard ASP.NET Core hosted blazor Web assembly template and replace
Index.razor with BackgroundServiceMulti.razor for using example code everything works fine in the Debug and Release mode
from Visual Studio.

But after dotnet publish -c Release
if you start the compiled server app
you will see:

image

Any plans to use SharedWorker?

Thanks for this library. I noticed in the source it is using Worker.js and interested if you have plans to use the SharedWorker.js instead?

Not 100% knowing what i'm talking about, but inspired by this library https://github.com/neomjs/neo it would be very useful to be able to popout a blazor component into its own browser tab - and port to existing worker seamlessly. Completely off the radar or not relevant to objectives of your library?

BlazorWorker.Demo.IoCExample error

MyIocService.cs
try
{
await this.WorkerMessageService.PostMessageAsync($"aaaaaaa"); // error
return this.AServiceDependency.Five();
}
finally
{
if (this.FiveCalledCounter > 2)
{
await this.WorkerMessageService.PostMessageAsync($"{nameof(FiveCalledCounter)} has been called more than 2 times: {this.FiveCalledCounter} times!"); // error
}
}

//////////////////////////////error message
dotnet.5.0.4.js:1 Uncaught Error: System.AggregateException: One or more errors occurred. (Unexpected character encountered while parsing value: F. Path '', line 0, position 0.)
---> Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: F. Path '', line 0, position 0.

Errors when using library

Folowing the instructions for the library, I get the errors below in the log. I have added all the assemblies I can think of as dependencies.
Code:
var worker = await _workerFactory.CreateAsync(); var service = await worker.CreateBackgroundServiceAsync<MyCPUIntensiveService>( options => options .AddConventionalAssemblyOfService() .AddAssemblies("Assm.Client", "Assm.Shared") ); var result = await service.RunAsync(s => s.MyMethod2(docMgr, "123"));

Errors:
a62b4eb3-d960-4b68-aae9-f344c72ecaa1:70 WASM-WORKER: undefined
Module.printErr @ a62b4eb3-d960-4b68-aae9-f344c72ecaa1:70
a62b4eb3-d960-4b68-aae9-f344c72ecaa1:28 Init method [BlazorWorker.WorkerBackgroundService]BlazorWorker.WorkerBackgroundService.WorkerInstanceManager:Init failed ReferenceError: showErrorNotification is not defined
at Module.printErr (a62b4eb3-d960-4b68-aae9-f344c72ecaa1:71)
at abort (dotnet.6.0.0-preview.7.21377.19.js:1)
at _abort (dotnet.6.0.0-preview.7.21377.19.js:1)
at dotnet.wasm:0x149430
at dotnet.wasm:0x7e687
at dotnet.wasm:0x66a5e
at dotnet.wasm:0x168e10
at dotnet.wasm:0x160079
at dotnet.wasm:0xaca88
at dotnet.wasm:0x1595d
onReady @ a62b4eb3-d960-4b68-aae9-f344c72ecaa1:28
a62b4eb3-d960-4b68-aae9-f344c72ecaa1:71 Uncaught (in promise) ReferenceError: showErrorNotification is not defined
at Module.printErr (a62b4eb3-d960-4b68-aae9-f344c72ecaa1:71)
at abort (dotnet.6.0.0-preview.7.21377.19.js:1)
at _abort (dotnet.6.0.0-preview.7.21377.19.js:1)
at dotnet.wasm:0x149430
at dotnet.wasm:0x7e687
at dotnet.wasm:0x66a5e
at dotnet.wasm:0x168e10
at dotnet.wasm:0x160079
at dotnet.wasm:0xaca88
at dotnet.wasm:0x1595d

System.Net.Http required version hard coded?

Getting this error in the browser when I try to use BlazorWorker:
WASM-WORKER: BlazorWorker.WorkerCore.SimpleInstanceService.SimpleInstanceService: 'GOSL.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is requesting missing assembly 'System.Net.Http, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

I am currently on .NET 5.0.3, is it possibly looking for 5.0.0 and not accepting anything higher?

Note, this is the first time I'm trying BlazorWorker, so it might be something else causing this!

Cannot read property 'forEach' of undefined

Running the example 'Http.razor' failed with following exception

Full exception:

Uncaught (in promise) TypeError: Cannot read property 'forEach' of undefined
    at 625a62e4-1e06-49d4-a926-1a3b78d58b8e:85
    at callRuntimeCallbacks (dotnet.3.2.0.js:1)
    at preRun (dotnet.3.2.0.js:1)
    at run (dotnet.3.2.0.js:1)
    at runCaller (dotnet.3.2.0.js:1)
    at removeRunDependency (dotnet.3.2.0.js:1)
    at receiveInstance (dotnet.3.2.0.js:1)
    at receiveInstantiatedSource (dotnet.3.2.0.js:1)

Code:

@page "/Http"
@inject IWorkerFactory workerFactory

<div class="row">
    <div class="col-5 col-xs-12">
        <h1>Using HttpClient</h1>

        This demo calls the github api from a new thread.

        <br /><br />

        <button disabled=@RunDisabled @onclick=OnClick class="btn btn-primary">Run test</button><br />
        <br />
        <br />
        <strong>Output:</strong>
        <hr />
<pre>
@output
</pre>
    </div>
    <div class="col-7 col-xs-12">
   
    </div>
</div>
@code {
    string output;
    IWorker worker;
    IWorkerBackgroundService<WebCallerService> backgroundService;
    string canDisposeWorker => worker == null ? null : "disabled";
    string canDisposeService => backgroundService == null ? null : "disabled";
    string RunDisabled => Running ? "disabled" : null;
    bool Running = false;
    private string rn = Environment.NewLine;

    public async Task OnClick(EventArgs _)
    {
        Running = true;
        output = "";
        try
        {

            if (worker == null)
            {
                worker = await workerFactory.CreateAsync();
            }

            var sw = new System.Diagnostics.Stopwatch();
            if (backgroundService == null)
            {
                output = $"{rn}{LogDate()} Creating background service...";
                StateHasChanged();

                sw.Start();
                backgroundService = await worker.CreateBackgroundServiceAsync<WebCallerService>(
                    options => options
                        .AddConventionalAssemblyOfService()
                        .AddHttpClient()
                );

                sw.Stop();
                output += $"{rn}{LogDate()} Background service created in {sw.ElapsedMilliseconds}ms";
                StateHasChanged();
            }

            output += $"{rn}{LogDate()} Calling Github WebService...";
            var result = await backgroundService.RunAsync(s => s.CallGitHubApi());

            output += $"{rn}{LogDate()} Result:{rn}{FormatJson(result)}";
            StateHasChanged();

        }
        catch (Exception e)
        {
            output += $"{rn}Error = {e}";
        }
        finally
        {
            Running = false;
        }
    }

    private string LogDate()
    {
        return DateTime.Now.ToString("HH:mm:ss:fff");
    }

    private static string FormatJson(string json)
    {
        var parsedJson = Newtonsoft.Json.JsonConvert.DeserializeObject(json);
        return Newtonsoft.Json.JsonConvert.SerializeObject(parsedJson, Newtonsoft.Json.Formatting.Indented);
    }
}

Sample request - BlazorWorker interacting with in-page JavaScript

BlazorWorker looks like a great way to incrementally add some .NET to an existing React/Angular/Vue/jQuery/whatever page or site.

Is there any chance of a tiny Demo where some JS in a page calls a method on a Blazor worker and the Blazor worker calls a JS method on the page?

I see for example BlazorWorker.WorkerCore.MessageService so I'm thinking this is stuff you've already built into BlazorWorker at least at some level, but I'm not spotting how to pull it together into a little sample app.

Send array [] to webworker

I am trying to send an image array to a webworker from Blazor C#.

//Blazor
await service.RunAsync(s => s.ImageAquired(imageBytes));

// Web worker

 public class FrequencyFinderService {
        public void ImageAquired(byte[] image)
        {
           // do stuff with the image
        }
    }

The problem is that the transfer of the image from Blazor to Webworker takes too much time. It locks up the UI. Is there a way to do this in an efficient manner?

I had a similar problem to get the image from JS to Blazor, but that solution was to use the "JSUnmarshalledRuntime.InvokeUnmarshalled"
var image = JSUnmarshalledRuntime.InvokeUnmarshalled<byte[]>("WebCamFunctions.snap");

Dependency Injection

Hi, great work.

Is there any way for worker.CreateBackgroundServiceAsync() to resolve all dependencies of TService? I have tried passing the service provider around but with no luck. Unfortunately the code I need running in the background is quite large and has a lot of dependencies.

Thanks

Local wasm app works, but published wasm app does not.

So before installing the BlazorWorker nuget package, I wasn't having any issue with my published build, but after doing so and using the web worker for a new background process, it works perfectly in chrome when I run locally with Visual Studio, but when I actually use the dotnet publish command and host the result on my static website, I get a ton of missing dlls and the web worker does not work.

I use the following command to publish:
dotnet publish ProjectName.csproj -c Release -o release --nologo

When I try to use the web worker functionality on the published version, I get this exception:
System.Runtime.Serialization.SerializationException: Error converting type: NoSetMethodForProperty, System.Runtime.Serialization.DateTimeOffsetAdapter, UtcDateTime

Here's images of the missing dlls:
image
image

Any idea how I can resolve this?

External dll reference gives error

Hello,
Thanks for sharing, this is very useful!

Is it possible to load external dll’s in the worker service methods? We have few math heavy simulation methods in an external dll, which takes several seconds to complete depending on the input measurements. I tried loading the dll but it gives below error. Have you done anything similar? Is it possible to use external dll’s? Please advise. Thank you!

Test-Worker-Error; ex.Message:Could not load type of field 'TestProject.Services.TestCPUIntensiveService:bb' (0) due to: Could not load file or assembly 'CPUIntensiveService.Model, Version=0.2.2.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.; ex.StackTrace: at BlazorWorker.BackgroundServiceFactory.WorkerBackgroundServiceProxy1[T].InitAsync (BlazorWorker.Core.WorkerInitOptions workerInitOptions) <0x38f3160 + 0x00740> in :0
at BlazorWorker.BackgroundServiceFactory.WorkerBackgroundServiceExtensions.CreateBackgroundServiceAsync[T] (BlazorWorker.Core.IWorker webWorkerProxy, BlazorWorker.Core.WorkerInitOptions workerInitOptions) <0x38c8820 + 0x00156> in :0
at TestProject.Pages.TestPage.RunWorker () [0x001b9] in \TestProject\Pages\TestPage.razor:193`

Not able to pass a third party type to function for Blazorworker

I am running into the issue of passing a file type into the function in runasync as shown here:

var service = await worker.CreateBackgroundServiceAsync<ExcelService>(
			  options => options
			  .AddConventionalAssemblyOfService()
			  .AddAssemblies("BlazorInputFile.dll")
			  .AddAssemblies("DocumentFormat.OpenXml.dll")
			  .AddAssemblies("DocumentFormat.OpenXml.Packaging.dll")
			  .AddAssemblies("DocumentFormat.OpenXml.Spreadsheet.dll")
			  .AddAssemblies("System.IO.Packaging.dll")
			  .AddAssemblies("System.Xml.Linq.dll")
			);
var result = await service.RunAsync(s => s.GetLinesFromSheet(files));

and I recieve error:

System.Runtime.Serialization.SerializationException: Error converting type: Type 'BlazorInputFile.FileListEntryImpl[]' with data contract name 'ArrayOfFileListEntryImpl:http://schemas.datacontract.org/2004/07/BlazorInputFile' is not expected.`

files is of type IFileEntry[] from the BlazorInputFile package. Is there a way to let the serviceworker know how to serialize this?

Javascript exception with Blazor Wasm .Net 5 RC 1

I am trying to use BlazorWorker in .Net 5 RC 1.

I am getting this exception in browser developer tools:

Uncaught (in promise) DOMException: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'https://localhost:44365/_framework/wasm/dotnet.5.0.0-rc.1.20451.14.js' failed to load.
    at blob:https://localhost:44365/4eab1338-d80a-4c4e-b704-aa7277d64a7c:140:22

Here is my code that I am trying to execute on the web-worker:

// Create worker.
var worker = await workerFactory.CreateAsync();

// Create service reference. For most scenarios, it's safe (and best) to keep this 
// reference around somewhere to avoid the startup cost.
var service = await worker.CreateBackgroundServiceAsync<CalculationService>();

// Reference that live outside of the current scope should not be passed into the expression.
 // To circumvent this, create a scope-local variable like this, and pass the local variable.
var localRigVariable = appState.CurrentRigBeingEdited;
var localReferenceDataVariable = appState.ReferenceDataQueryResponse;
var result = await service.RunAsync(s => s.RecalculateActivities(localRigVariable, localReferenceDataVariable));

Replace XMLHttpRequest with fetch to hook on cache

The following code mirrors an old version of the blazor assembly loader

return new Promise((resolve, reject) => {

The "new" (3.2.0?) version of blazor uses resource caching with fetch (service worker?), this should be mirrored in BlazorWorker to take advantage of request caching, has the potential to speed up worker initialization down to 0 requests for most cases.

not sure if practically feasable to hook on to the cache used here: https://github.com/dotnet/aspnetcore/blob/7a9707eb98c9e82d2fdbc25de541bf60d4bb46ca/src/Components/Web.JS/src/Platform/WebAssemblyResourceLoader.ts#L77 but certainly worth an investigation

Streaming

Implement Stream support in the service contract (either as an argument or as a return type).

BlazorWorker.WorkerCore

Not sure if i'm doing something wrong, but i had to download the source and compile my own version of BlazorWorker.WorkerCore package to get IWorker to be included. Something is not working as it should.

image

after publishing
BlazorWorker.WorkerCore to a nuget package and including that from a local repository everything worked fine.
Still working on getting the whole thing working so not sure if that is good. But at least this should be fixed i think.

Great work on this nonetheless, awesome unique content with a lot of promise!

Webworker with stimulsoft

I'm trying to wrap Stimulsoft reports Blazer report viewer and I'm stuck trying to get the report to render, any ideas? I grabbed the latest code and I've been messing with SetEnv("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT", "0 / 1 / false / true") or even creating a custom culture and I'm stuck

   WASM-WORKER: System.Globalization.CultureNotFoundException: Only the invariant culture is supported in globalization-invariant mode. See https://aka.ms/GlobalizationInvariantMode for more information. (Parameter 'name') Arguments(0)

module.printErr @ 249eddc0-55e2-4f16-b56f-ca43f42a0827:69
put_char @ dotnet.6.0.4.dckq00jdfr.js:1
write @ dotnet.6.0.4.dckq00jdfr.js:1
write @ dotnet.6.0.4.dckq00jdfr.js:1
doWritev @ dotnet.6.0.4.dckq00jdfr.js:1
_fd_write @ dotnet.6.0.4.dckq00jdfr.js:1
$func8818 @ dotnet.wasm:0x1d07bf
$func4016 @ dotnet.wasm:0xeaa77
$func219 @ dotnet.wasm:0x1a077
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1619 @ dotnet.wasm:0x6ffa2
$mono_wasm_invoke_method @ dotnet.wasm:0x969b
Module._mono_wasm_invoke_method @ dotnet.6.0.4.dckq00jdfr.js:1
managed_BINDINGS_SetTaskSourceResult @ managed_BINDINGS_SetTaskSourceResult:17
(anonymous) @ dotnet.6.0.4.dckq00jdfr.js:1
Promise.then (async)
_wrap_js_thenable_as_task @ dotnet.6.0.4.dckq00jdfr.js:1
_js_to_mono_obj @ dotnet.6.0.4.dckq00jdfr.js:1
_mono_wasm_invoke_js_with_args @ dotnet.6.0.4.dckq00jdfr.js:1
$func219 @ dotnet.wasm:0x1a0b4
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1619 @ dotnet.wasm:0x6ffa2
$mono_wasm_invoke_method @ dotnet.wasm:0x969b
Module._mono_wasm_invoke_method @ dotnet.6.0.4.dckq00jdfr.js:1
managed_BINDINGS_SetTaskSourceResult @ managed_BINDINGS_SetTaskSourceResult:17
(anonymous) @ dotnet.6.0.4.dckq00jdfr.js:1
Promise.then (async)
_wrap_js_thenable_as_task @ dotnet.6.0.4.dckq00jdfr.js:1
_js_to_mono_obj @ dotnet.6.0.4.dckq00jdfr.js:1
_mono_wasm_invoke_js_with_args @ dotnet.6.0.4.dckq00jdfr.js:1
$func219 @ dotnet.wasm:0x1a0b4
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1613 @ dotnet.wasm:0x6f8a7
$func966 @ dotnet.wasm:0x502f8
$func219 @ dotnet.wasm:0x1a0b4
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1619 @ dotnet.wasm:0x6ffa2
$func3213 @ dotnet.wasm:0xc4abd
$mono_background_exec @ dotnet.wasm:0x93f6d
Module._mono_background_exec @ dotnet.6.0.4.dckq00jdfr.js:1
pump_message @ dotnet.6.0.4.dckq00jdfr.js:1
setTimeout (async)
_schedule_background_exec @ dotnet.6.0.4.dckq00jdfr.js:1
$func2387 @ dotnet.wasm:0x93f1e
$func3212 @ dotnet.wasm:0xc4a4d
$func219 @ dotnet.wasm:0x1a163
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1619 @ dotnet.wasm:0x6ffa2
$mono_wasm_invoke_method @ dotnet.wasm:0x969b
Module._mono_wasm_invoke_method @ dotnet.6.0.4.dckq00jdfr.js:1
managed__BlazorWorker_WorkerCore_BlazorWorker_WorkerCore_MessageService_OnMessage @ managed__BlazorWorker_WorkerCore_BlazorWorker_WorkerCore_MessageService_OnMessage:16
self.onmessage @ 249eddc0-55e2-4f16-b56f-ca43f42a0827:17
249eddc0-55e2-4f16-b56f-ca43f42a0827:69

   WASM-WORKER: en-US is an invalid culture identifier. Arguments(0)

module.printErr @ 249eddc0-55e2-4f16-b56f-ca43f42a0827:69
put_char @ dotnet.6.0.4.dckq00jdfr.js:1
write @ dotnet.6.0.4.dckq00jdfr.js:1
write @ dotnet.6.0.4.dckq00jdfr.js:1
doWritev @ dotnet.6.0.4.dckq00jdfr.js:1
_fd_write @ dotnet.6.0.4.dckq00jdfr.js:1
$func8818 @ dotnet.wasm:0x1d07bf
$func4016 @ dotnet.wasm:0xeaa77
$func219 @ dotnet.wasm:0x1a077
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1619 @ dotnet.wasm:0x6ffa2
$mono_wasm_invoke_method @ dotnet.wasm:0x969b
Module._mono_wasm_invoke_method @ dotnet.6.0.4.dckq00jdfr.js:1
managed_BINDINGS_SetTaskSourceResult @ managed_BINDINGS_SetTaskSourceResult:17
(anonymous) @ dotnet.6.0.4.dckq00jdfr.js:1
Promise.then (async)
_wrap_js_thenable_as_task @ dotnet.6.0.4.dckq00jdfr.js:1
_js_to_mono_obj @ dotnet.6.0.4.dckq00jdfr.js:1
_mono_wasm_invoke_js_with_args @ dotnet.6.0.4.dckq00jdfr.js:1
$func219 @ dotnet.wasm:0x1a0b4
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1619 @ dotnet.wasm:0x6ffa2
$mono_wasm_invoke_method @ dotnet.wasm:0x969b
Module._mono_wasm_invoke_method @ dotnet.6.0.4.dckq00jdfr.js:1
managed_BINDINGS_SetTaskSourceResult @ managed_BINDINGS_SetTaskSourceResult:17
(anonymous) @ dotnet.6.0.4.dckq00jdfr.js:1
Promise.then (async)
_wrap_js_thenable_as_task @ dotnet.6.0.4.dckq00jdfr.js:1
_js_to_mono_obj @ dotnet.6.0.4.dckq00jdfr.js:1
_mono_wasm_invoke_js_with_args @ dotnet.6.0.4.dckq00jdfr.js:1
$func219 @ dotnet.wasm:0x1a0b4
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1613 @ dotnet.wasm:0x6f8a7
$func966 @ dotnet.wasm:0x502f8
$func219 @ dotnet.wasm:0x1a0b4
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1619 @ dotnet.wasm:0x6ffa2
$func3213 @ dotnet.wasm:0xc4abd
$mono_background_exec @ dotnet.wasm:0x93f6d
Module._mono_background_exec @ dotnet.6.0.4.dckq00jdfr.js:1
pump_message @ dotnet.6.0.4.dckq00jdfr.js:1
setTimeout (async)
_schedule_background_exec @ dotnet.6.0.4.dckq00jdfr.js:1
$func2387 @ dotnet.wasm:0x93f1e
$func3212 @ dotnet.wasm:0xc4a4d
$func219 @ dotnet.wasm:0x1a163
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1619 @ dotnet.wasm:0x6ffa2
$mono_wasm_invoke_method @ dotnet.wasm:0x969b
Module._mono_wasm_invoke_method @ dotnet.6.0.4.dckq00jdfr.js:1
managed__BlazorWorker_WorkerCore_BlazorWorker_WorkerCore_MessageService_OnMessage @ managed__BlazorWorker_WorkerCore_BlazorWorker_WorkerCore_MessageService_OnMessage:16
self.onmessage @ 249eddc0-55e2-4f16-b56f-ca43f42a0827:17
249eddc0-55e2-4f16-b56f-ca43f42a0827:69

   WASM-WORKER:    at System.Globalization.CultureInfo..ctor(String name, Boolean useUserOverride) Arguments(0)

module.printErr @ 249eddc0-55e2-4f16-b56f-ca43f42a0827:69
put_char @ dotnet.6.0.4.dckq00jdfr.js:1
write @ dotnet.6.0.4.dckq00jdfr.js:1
write @ dotnet.6.0.4.dckq00jdfr.js:1
doWritev @ dotnet.6.0.4.dckq00jdfr.js:1
_fd_write @ dotnet.6.0.4.dckq00jdfr.js:1
$func8818 @ dotnet.wasm:0x1d07bf
$func4016 @ dotnet.wasm:0xeaa77
$func219 @ dotnet.wasm:0x1a077
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1619 @ dotnet.wasm:0x6ffa2
$mono_wasm_invoke_method @ dotnet.wasm:0x969b
Module._mono_wasm_invoke_method @ dotnet.6.0.4.dckq00jdfr.js:1
managed_BINDINGS_SetTaskSourceResult @ managed_BINDINGS_SetTaskSourceResult:17
(anonymous) @ dotnet.6.0.4.dckq00jdfr.js:1
Promise.then (async)
_wrap_js_thenable_as_task @ dotnet.6.0.4.dckq00jdfr.js:1
_js_to_mono_obj @ dotnet.6.0.4.dckq00jdfr.js:1
_mono_wasm_invoke_js_with_args @ dotnet.6.0.4.dckq00jdfr.js:1
$func219 @ dotnet.wasm:0x1a0b4
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1619 @ dotnet.wasm:0x6ffa2
$mono_wasm_invoke_method @ dotnet.wasm:0x969b
Module._mono_wasm_invoke_method @ dotnet.6.0.4.dckq00jdfr.js:1
managed_BINDINGS_SetTaskSourceResult @ managed_BINDINGS_SetTaskSourceResult:17
(anonymous) @ dotnet.6.0.4.dckq00jdfr.js:1
Promise.then (async)
_wrap_js_thenable_as_task @ dotnet.6.0.4.dckq00jdfr.js:1
_js_to_mono_obj @ dotnet.6.0.4.dckq00jdfr.js:1
_mono_wasm_invoke_js_with_args @ dotnet.6.0.4.dckq00jdfr.js:1
$func219 @ dotnet.wasm:0x1a0b4
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1613 @ dotnet.wasm:0x6f8a7
$func966 @ dotnet.wasm:0x502f8
$func219 @ dotnet.wasm:0x1a0b4
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1619 @ dotnet.wasm:0x6ffa2
$func3213 @ dotnet.wasm:0xc4abd
$mono_background_exec @ dotnet.wasm:0x93f6d
Module._mono_background_exec @ dotnet.6.0.4.dckq00jdfr.js:1
pump_message @ dotnet.6.0.4.dckq00jdfr.js:1
setTimeout (async)
_schedule_background_exec @ dotnet.6.0.4.dckq00jdfr.js:1
$func2387 @ dotnet.wasm:0x93f1e
$func3212 @ dotnet.wasm:0xc4a4d
$func219 @ dotnet.wasm:0x1a163
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1619 @ dotnet.wasm:0x6ffa2
$mono_wasm_invoke_method @ dotnet.wasm:0x969b
Module._mono_wasm_invoke_method @ dotnet.6.0.4.dckq00jdfr.js:1
managed__BlazorWorker_WorkerCore_BlazorWorker_WorkerCore_MessageService_OnMessage @ managed__BlazorWorker_WorkerCore_BlazorWorker_WorkerCore_MessageService_OnMessage:16
self.onmessage @ 249eddc0-55e2-4f16-b56f-ca43f42a0827:17
249eddc0-55e2-4f16-b56f-ca43f42a0827:69

   WASM-WORKER:    at Stimulsoft.Base.Serializing.StiSerializing.Deserialize(Object obj, Stream stream, String application) Arguments(0)

module.printErr @ 249eddc0-55e2-4f16-b56f-ca43f42a0827:69
put_char @ dotnet.6.0.4.dckq00jdfr.js:1
write @ dotnet.6.0.4.dckq00jdfr.js:1
write @ dotnet.6.0.4.dckq00jdfr.js:1
doWritev @ dotnet.6.0.4.dckq00jdfr.js:1
_fd_write @ dotnet.6.0.4.dckq00jdfr.js:1
$func8818 @ dotnet.wasm:0x1d07bf
$func4016 @ dotnet.wasm:0xeaa77
$func219 @ dotnet.wasm:0x1a077
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1619 @ dotnet.wasm:0x6ffa2
$mono_wasm_invoke_method @ dotnet.wasm:0x969b
Module._mono_wasm_invoke_method @ dotnet.6.0.4.dckq00jdfr.js:1
managed_BINDINGS_SetTaskSourceResult @ managed_BINDINGS_SetTaskSourceResult:17
(anonymous) @ dotnet.6.0.4.dckq00jdfr.js:1
Promise.then (async)
_wrap_js_thenable_as_task @ dotnet.6.0.4.dckq00jdfr.js:1
_js_to_mono_obj @ dotnet.6.0.4.dckq00jdfr.js:1
_mono_wasm_invoke_js_with_args @ dotnet.6.0.4.dckq00jdfr.js:1
$func219 @ dotnet.wasm:0x1a0b4
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1619 @ dotnet.wasm:0x6ffa2
$mono_wasm_invoke_method @ dotnet.wasm:0x969b
Module._mono_wasm_invoke_method @ dotnet.6.0.4.dckq00jdfr.js:1
managed_BINDINGS_SetTaskSourceResult @ managed_BINDINGS_SetTaskSourceResult:17
(anonymous) @ dotnet.6.0.4.dckq00jdfr.js:1
Promise.then (async)
_wrap_js_thenable_as_task @ dotnet.6.0.4.dckq00jdfr.js:1
_js_to_mono_obj @ dotnet.6.0.4.dckq00jdfr.js:1
_mono_wasm_invoke_js_with_args @ dotnet.6.0.4.dckq00jdfr.js:1
$func219 @ dotnet.wasm:0x1a0b4
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1613 @ dotnet.wasm:0x6f8a7
$func966 @ dotnet.wasm:0x502f8
$func219 @ dotnet.wasm:0x1a0b4
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1619 @ dotnet.wasm:0x6ffa2
$func3213 @ dotnet.wasm:0xc4abd
$mono_background_exec @ dotnet.wasm:0x93f6d
Module._mono_background_exec @ dotnet.6.0.4.dckq00jdfr.js:1
pump_message @ dotnet.6.0.4.dckq00jdfr.js:1
setTimeout (async)
_schedule_background_exec @ dotnet.6.0.4.dckq00jdfr.js:1
$func2387 @ dotnet.wasm:0x93f1e
$func3212 @ dotnet.wasm:0xc4a4d
$func219 @ dotnet.wasm:0x1a163
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1619 @ dotnet.wasm:0x6ffa2
$mono_wasm_invoke_method @ dotnet.wasm:0x969b
Module._mono_wasm_invoke_method @ dotnet.6.0.4.dckq00jdfr.js:1
managed__BlazorWorker_WorkerCore_BlazorWorker_WorkerCore_MessageService_OnMessage @ managed__BlazorWorker_WorkerCore_BlazorWorker_WorkerCore_MessageService_OnMessage:16
self.onmessage @ 249eddc0-55e2-4f16-b56f-ca43f42a0827:17
249eddc0-55e2-4f16-b56f-ca43f42a0827:69

   WASM-WORKER:    at Stimulsoft.Report.SaveLoad.StiXmlDocumentSLService.Load(StiReport report, Stream stream) Arguments(0)

module.printErr @ 249eddc0-55e2-4f16-b56f-ca43f42a0827:69
put_char @ dotnet.6.0.4.dckq00jdfr.js:1
write @ dotnet.6.0.4.dckq00jdfr.js:1
write @ dotnet.6.0.4.dckq00jdfr.js:1
doWritev @ dotnet.6.0.4.dckq00jdfr.js:1
_fd_write @ dotnet.6.0.4.dckq00jdfr.js:1
$func8818 @ dotnet.wasm:0x1d07bf
$func4016 @ dotnet.wasm:0xeaa77
$func219 @ dotnet.wasm:0x1a077
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1619 @ dotnet.wasm:0x6ffa2
$mono_wasm_invoke_method @ dotnet.wasm:0x969b
Module._mono_wasm_invoke_method @ dotnet.6.0.4.dckq00jdfr.js:1
managed_BINDINGS_SetTaskSourceResult @ managed_BINDINGS_SetTaskSourceResult:17
(anonymous) @ dotnet.6.0.4.dckq00jdfr.js:1
Promise.then (async)
_wrap_js_thenable_as_task @ dotnet.6.0.4.dckq00jdfr.js:1
_js_to_mono_obj @ dotnet.6.0.4.dckq00jdfr.js:1
_mono_wasm_invoke_js_with_args @ dotnet.6.0.4.dckq00jdfr.js:1
$func219 @ dotnet.wasm:0x1a0b4
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1619 @ dotnet.wasm:0x6ffa2
$mono_wasm_invoke_method @ dotnet.wasm:0x969b
Module._mono_wasm_invoke_method @ dotnet.6.0.4.dckq00jdfr.js:1
managed_BINDINGS_SetTaskSourceResult @ managed_BINDINGS_SetTaskSourceResult:17
(anonymous) @ dotnet.6.0.4.dckq00jdfr.js:1
Promise.then (async)
_wrap_js_thenable_as_task @ dotnet.6.0.4.dckq00jdfr.js:1
_js_to_mono_obj @ dotnet.6.0.4.dckq00jdfr.js:1
_mono_wasm_invoke_js_with_args @ dotnet.6.0.4.dckq00jdfr.js:1
$func219 @ dotnet.wasm:0x1a0b4
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1613 @ dotnet.wasm:0x6f8a7
$func966 @ dotnet.wasm:0x502f8
$func219 @ dotnet.wasm:0x1a0b4
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1619 @ dotnet.wasm:0x6ffa2
$func3213 @ dotnet.wasm:0xc4abd
$mono_background_exec @ dotnet.wasm:0x93f6d
Module._mono_background_exec @ dotnet.6.0.4.dckq00jdfr.js:1
pump_message @ dotnet.6.0.4.dckq00jdfr.js:1
setTimeout (async)
_schedule_background_exec @ dotnet.6.0.4.dckq00jdfr.js:1
$func2387 @ dotnet.wasm:0x93f1e
$func3212 @ dotnet.wasm:0xc4a4d
$func219 @ dotnet.wasm:0x1a163
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1619 @ dotnet.wasm:0x6ffa2
$mono_wasm_invoke_method @ dotnet.wasm:0x969b
Module._mono_wasm_invoke_method @ dotnet.6.0.4.dckq00jdfr.js:1
managed__BlazorWorker_WorkerCore_BlazorWorker_WorkerCore_MessageService_OnMessage @ managed__BlazorWorker_WorkerCore_BlazorWorker_WorkerCore_MessageService_OnMessage:16
self.onmessage @ 249eddc0-55e2-4f16-b56f-ca43f42a0827:17
249eddc0-55e2-4f16-b56f-ca43f42a0827:69

   WASM-WORKER:    at Stimulsoft.Report.StiReport.LoadDocument(StiDocumentSLService service, Stream stream) Arguments(0)

module.printErr @ 249eddc0-55e2-4f16-b56f-ca43f42a0827:69
put_char @ dotnet.6.0.4.dckq00jdfr.js:1
write @ dotnet.6.0.4.dckq00jdfr.js:1
write @ dotnet.6.0.4.dckq00jdfr.js:1
doWritev @ dotnet.6.0.4.dckq00jdfr.js:1
_fd_write @ dotnet.6.0.4.dckq00jdfr.js:1
$func8818 @ dotnet.wasm:0x1d07bf
$func4016 @ dotnet.wasm:0xeaa77
$func219 @ dotnet.wasm:0x1a077
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1619 @ dotnet.wasm:0x6ffa2
$mono_wasm_invoke_method @ dotnet.wasm:0x969b
Module._mono_wasm_invoke_method @ dotnet.6.0.4.dckq00jdfr.js:1
managed_BINDINGS_SetTaskSourceResult @ managed_BINDINGS_SetTaskSourceResult:17
(anonymous) @ dotnet.6.0.4.dckq00jdfr.js:1
Promise.then (async)
_wrap_js_thenable_as_task @ dotnet.6.0.4.dckq00jdfr.js:1
_js_to_mono_obj @ dotnet.6.0.4.dckq00jdfr.js:1
_mono_wasm_invoke_js_with_args @ dotnet.6.0.4.dckq00jdfr.js:1
$func219 @ dotnet.wasm:0x1a0b4
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1619 @ dotnet.wasm:0x6ffa2
$mono_wasm_invoke_method @ dotnet.wasm:0x969b
Module._mono_wasm_invoke_method @ dotnet.6.0.4.dckq00jdfr.js:1
managed_BINDINGS_SetTaskSourceResult @ managed_BINDINGS_SetTaskSourceResult:17
(anonymous) @ dotnet.6.0.4.dckq00jdfr.js:1
Promise.then (async)
_wrap_js_thenable_as_task @ dotnet.6.0.4.dckq00jdfr.js:1
_js_to_mono_obj @ dotnet.6.0.4.dckq00jdfr.js:1
_mono_wasm_invoke_js_with_args @ dotnet.6.0.4.dckq00jdfr.js:1
$func219 @ dotnet.wasm:0x1a0b4
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1613 @ dotnet.wasm:0x6f8a7
$func966 @ dotnet.wasm:0x502f8
$func219 @ dotnet.wasm:0x1a0b4
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1619 @ dotnet.wasm:0x6ffa2
$func3213 @ dotnet.wasm:0xc4abd
$mono_background_exec @ dotnet.wasm:0x93f6d
Module._mono_background_exec @ dotnet.6.0.4.dckq00jdfr.js:1
pump_message @ dotnet.6.0.4.dckq00jdfr.js:1
setTimeout (async)
_schedule_background_exec @ dotnet.6.0.4.dckq00jdfr.js:1
$func2387 @ dotnet.wasm:0x93f1e
$func3212 @ dotnet.wasm:0xc4a4d
$func219 @ dotnet.wasm:0x1a163
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1619 @ dotnet.wasm:0x6ffa2
$mono_wasm_invoke_method @ dotnet.wasm:0x969b
Module._mono_wasm_invoke_method @ dotnet.6.0.4.dckq00jdfr.js:1
managed__BlazorWorker_WorkerCore_BlazorWorker_WorkerCore_MessageService_OnMessage @ managed__BlazorWorker_WorkerCore_BlazorWorker_WorkerCore_MessageService_OnMessage:16
self.onmessage @ 249eddc0-55e2-4f16-b56f-ca43f42a0827:17
249eddc0-55e2-4f16-b56f-ca43f42a0827:69

   WASM-WORKER:    at Stimulsoft.Report.StiReport.LoadDocument(Stream stream) Arguments(0)

module.printErr @ 249eddc0-55e2-4f16-b56f-ca43f42a0827:69
put_char @ dotnet.6.0.4.dckq00jdfr.js:1
write @ dotnet.6.0.4.dckq00jdfr.js:1
write @ dotnet.6.0.4.dckq00jdfr.js:1
doWritev @ dotnet.6.0.4.dckq00jdfr.js:1
_fd_write @ dotnet.6.0.4.dckq00jdfr.js:1
$func8818 @ dotnet.wasm:0x1d07bf
$func4016 @ dotnet.wasm:0xeaa77
$func219 @ dotnet.wasm:0x1a077
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1619 @ dotnet.wasm:0x6ffa2
$mono_wasm_invoke_method @ dotnet.wasm:0x969b
Module._mono_wasm_invoke_method @ dotnet.6.0.4.dckq00jdfr.js:1
managed_BINDINGS_SetTaskSourceResult @ managed_BINDINGS_SetTaskSourceResult:17
(anonymous) @ dotnet.6.0.4.dckq00jdfr.js:1
Promise.then (async)
_wrap_js_thenable_as_task @ dotnet.6.0.4.dckq00jdfr.js:1
_js_to_mono_obj @ dotnet.6.0.4.dckq00jdfr.js:1
_mono_wasm_invoke_js_with_args @ dotnet.6.0.4.dckq00jdfr.js:1
$func219 @ dotnet.wasm:0x1a0b4
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1619 @ dotnet.wasm:0x6ffa2
$mono_wasm_invoke_method @ dotnet.wasm:0x969b
Module._mono_wasm_invoke_method @ dotnet.6.0.4.dckq00jdfr.js:1
managed_BINDINGS_SetTaskSourceResult @ managed_BINDINGS_SetTaskSourceResult:17
(anonymous) @ dotnet.6.0.4.dckq00jdfr.js:1
Promise.then (async)
_wrap_js_thenable_as_task @ dotnet.6.0.4.dckq00jdfr.js:1
_js_to_mono_obj @ dotnet.6.0.4.dckq00jdfr.js:1
_mono_wasm_invoke_js_with_args @ dotnet.6.0.4.dckq00jdfr.js:1
$func219 @ dotnet.wasm:0x1a0b4
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1613 @ dotnet.wasm:0x6f8a7
$func966 @ dotnet.wasm:0x502f8
$func219 @ dotnet.wasm:0x1a0b4
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1619 @ dotnet.wasm:0x6ffa2
$func3213 @ dotnet.wasm:0xc4abd
$mono_background_exec @ dotnet.wasm:0x93f6d
Module._mono_background_exec @ dotnet.6.0.4.dckq00jdfr.js:1
pump_message @ dotnet.6.0.4.dckq00jdfr.js:1
setTimeout (async)
_schedule_background_exec @ dotnet.6.0.4.dckq00jdfr.js:1
$func2387 @ dotnet.wasm:0x93f1e
$func3212 @ dotnet.wasm:0xc4a4d
$func219 @ dotnet.wasm:0x1a163
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1619 @ dotnet.wasm:0x6ffa2
$mono_wasm_invoke_method @ dotnet.wasm:0x969b
Module._mono_wasm_invoke_method @ dotnet.6.0.4.dckq00jdfr.js:1
managed__BlazorWorker_WorkerCore_BlazorWorker_WorkerCore_MessageService_OnMessage @ managed__BlazorWorker_WorkerCore_BlazorWorker_WorkerCore_MessageService_OnMessage:16
self.onmessage @ 249eddc0-55e2-4f16-b56f-ca43f42a0827:17
249eddc0-55e2-4f16-b56f-ca43f42a0827:69

   WASM-WORKER:    at Stimulsoft.Report.StiReport.LoadDocument(Byte[] bytes) Arguments(0)

module.printErr @ 249eddc0-55e2-4f16-b56f-ca43f42a0827:69
put_char @ dotnet.6.0.4.dckq00jdfr.js:1
write @ dotnet.6.0.4.dckq00jdfr.js:1
write @ dotnet.6.0.4.dckq00jdfr.js:1
doWritev @ dotnet.6.0.4.dckq00jdfr.js:1
_fd_write @ dotnet.6.0.4.dckq00jdfr.js:1
$func8818 @ dotnet.wasm:0x1d07bf
$func4016 @ dotnet.wasm:0xeaa77
$func219 @ dotnet.wasm:0x1a077
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1619 @ dotnet.wasm:0x6ffa2
$mono_wasm_invoke_method @ dotnet.wasm:0x969b
Module._mono_wasm_invoke_method @ dotnet.6.0.4.dckq00jdfr.js:1
managed_BINDINGS_SetTaskSourceResult @ managed_BINDINGS_SetTaskSourceResult:17
(anonymous) @ dotnet.6.0.4.dckq00jdfr.js:1
Promise.then (async)
_wrap_js_thenable_as_task @ dotnet.6.0.4.dckq00jdfr.js:1
_js_to_mono_obj @ dotnet.6.0.4.dckq00jdfr.js:1
_mono_wasm_invoke_js_with_args @ dotnet.6.0.4.dckq00jdfr.js:1
$func219 @ dotnet.wasm:0x1a0b4
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1619 @ dotnet.wasm:0x6ffa2
$mono_wasm_invoke_method @ dotnet.wasm:0x969b
Module._mono_wasm_invoke_method @ dotnet.6.0.4.dckq00jdfr.js:1
managed_BINDINGS_SetTaskSourceResult @ managed_BINDINGS_SetTaskSourceResult:17
(anonymous) @ dotnet.6.0.4.dckq00jdfr.js:1
Promise.then (async)
_wrap_js_thenable_as_task @ dotnet.6.0.4.dckq00jdfr.js:1
_js_to_mono_obj @ dotnet.6.0.4.dckq00jdfr.js:1
_mono_wasm_invoke_js_with_args @ dotnet.6.0.4.dckq00jdfr.js:1
$func219 @ dotnet.wasm:0x1a0b4
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1613 @ dotnet.wasm:0x6f8a7
$func966 @ dotnet.wasm:0x502f8
$func219 @ dotnet.wasm:0x1a0b4
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1619 @ dotnet.wasm:0x6ffa2
$func3213 @ dotnet.wasm:0xc4abd
$mono_background_exec @ dotnet.wasm:0x93f6d
Module._mono_background_exec @ dotnet.6.0.4.dckq00jdfr.js:1
pump_message @ dotnet.6.0.4.dckq00jdfr.js:1
setTimeout (async)
_schedule_background_exec @ dotnet.6.0.4.dckq00jdfr.js:1
$func2387 @ dotnet.wasm:0x93f1e
$func3212 @ dotnet.wasm:0xc4a4d
$func219 @ dotnet.wasm:0x1a163
$func167 @ dotnet.wasm:0xcac9
$func166 @ dotnet.wasm:0xb9dc
$func2810 @ dotnet.wasm:0xabb22
$func1615 @ dotnet.wasm:0x6f935
$func1619 @ dotnet.wasm:0x6ffa2
$mono_wasm_invoke_method @ dotnet.wasm:0x969b
Module._mono_wasm_invoke_method @ dotnet.6.0.4.dckq00jdfr.js:1
managed__BlazorWorker_WorkerCore_BlazorWorker_WorkerCore_MessageService_OnMessage @ managed__BlazorWorker_WorkerCore_BlazorWorker_WorkerCore_MessageService_OnMessage:16
self.onmessage @ 249eddc0-55e2-4f16-b56f-ca43f42a0827:17
249eddc0-55e2-4f16-b56f-ca43f42a0827:69

   WASM-WORKER:    at Showing_a_Report_in_the_Viewer.Pages.MyCPUIntensiveService.MyMethod(Uri hostAddress) Arguments(0)

[Question] JS Invoke

Can I invoke JS from my C# code in the worker service?
If yes, can you provide a small example of how?

IndexedDb / JsInterop

Is there a way for the worker to load javascript for JsInterop, specifically to get IndexedDb working?

I am currently using the package https://github.com/wtulloch/Blazor.IndexedDB and am able to resolve dependencies fine and return the IndexedDBManager.Name. However actually communicating with the db results in the process just hanging. I think this might be because we need to pass the interop script TG.Blazor.IndexedDB/indexedDb.Blazor.js somehow.

Release Builds don't Works

My program run fine in debug build, but when I build as Release, I got a Method not found error (WebAssembly.Runtime:GetDateValue)
image
First I didn't know from where this happen, but after take a look the WebAssembly.Runtime is from the WebAssembly.Bindings; and this is one of the dependencies of the BlazorWorker.WorkerCore;
And then, i'm here now :)

This probabbly isn't your fault, but I really don't know what I do now...

.Net 6

Is .Net6 supported yet? Or are there work arounds to get it to work?

I used the standart example from this git:


var worker = await workerFactory.CreateAsync();

var service = await worker.CreateBackgroundServiceAsync<TestService>();

var localParameterValue = 42;
var result = await service.RunAsync(s => s.MyMethod(localParameterValue));
public class TestService
{
    public int MyMethod(int parameter)
    {
        int i = 0;
        while (i < 5000000) i += (i * parameter);
        return i;
    }
}

and got:
/__w/1/s/src/mono/mono/metadata/icall.c:6639 <disabled> dotnet.6.0.0-preview.7.21377.19.js:1:17346

WASM-WORKER: undefined 65ddd4df-7800-4bcd-87e3-c2164e3ffdda:70:21
    printErr blob:https://localhost:5001/65ddd4df-7800-4bcd-87e3-c2164e3ffdda:70
    abort https://localhost:5001/_framework/dotnet.6.0.0-preview.7.21377.19.js:1
    _abort https://localhost:5001/_framework/dotnet.6.0.0-preview.7.21377.19.js:1
    <anonym> https://localhost:5001/_framework/dotnet.wasm:1348656
    <anonym> https://localhost:5001/_framework/dotnet.wasm:517767
    <anonym> https://localhost:5001/_framework/dotnet.wasm:420446
    <anonym> https://localhost:5001/_framework/dotnet.wasm:1478160
    <anonym> https://localhost:5001/_framework/dotnet.wasm:1441913
    <anonym> https://localhost:5001/_framework/dotnet.wasm:707208
    <anonym> https://localhost:5001/_framework/dotnet.wasm:88413
    <anonym> https://localhost:5001/_framework/dotnet.wasm:41808
    <anonym> https://localhost:5001/_framework/dotnet.wasm:284802
    <anonym> https://localhost:5001/_framework/dotnet.wasm:1245660
    <anonym> https://localhost:5001/_framework/dotnet.wasm:468414
    <anonym> https://localhost:5001/_framework/dotnet.wasm:1478160
    <anonym> https://localhost:5001/_framework/dotnet.wasm:1441913
    <anonym> https://localhost:5001/_framework/dotnet.wasm:707208
    <anonym> https://localhost:5001/_framework/dotnet.wasm:88413
    <anonym> https://localhost:5001/_framework/dotnet.wasm:41808
    <anonym> https://localhost:5001/_framework/dotnet.wasm:284802
    <anonym> https://localhost:5001/_framework/dotnet.wasm:1245660
    <anonym> https://localhost:5001/_framework/dotnet.wasm:468414
    <anonym> https://localhost:5001/_framework/dotnet.wasm:1478160
    <anonym> https://localhost:5001/_framework/dotnet.wasm:1441913
    <anonym> https://localhost:5001/_framework/dotnet.wasm:707208
    <anonym> https://localhost:5001/_framework/dotnet.wasm:88413
    <anonym> https://localhost:5001/_framework/dotnet.wasm:41808
    <anonym> https://localhost:5001/_framework/dotnet.wasm:447521
    <anonym> https://localhost:5001/_framework/dotnet.wasm:1478160
    <anonym> https://localhost:5001/_framework/dotnet.wasm:1441913
    <anonym> https://localhost:5001/_framework/dotnet.wasm:707208
    <anonym> https://localhost:5001/_framework/dotnet.wasm:88413
    <anonym> https://localhost:5001/_framework/dotnet.wasm:1428159
    _mono_wasm_invoke_method https://localhost:5001/_framework/dotnet.6.0.0-preview.7.21377.19.js:1
    _call_method_with_converted_args https://localhost:5001/_framework/dotnet.6.0.0-preview.7.21377.19.js:1
    call_method https://localhost:5001/_framework/dotnet.6.0.0-preview.7.21377.19.js:1
    call_static_method https://localhost:5001/_framework/dotnet.6.0.0-preview.7.21377.19.js:1
    onReady blob:https://localhost:5001/65ddd4df-7800-4bcd-87e3-c2164e3ffdda:26
    onmessage blob:https://localhost:5001/65ddd4df-7800-4bcd-87e3-c2164e3ffdda:134
    callRuntimeCallbacks https://localhost:5001/_framework/dotnet.6.0.0-preview.7.21377.19.js:1
    postRun https://localhost:5001/_framework/dotnet.6.0.0-preview.7.21377.19.js:1
    doRun https://localhost:5001/_framework/dotnet.6.0.0-preview.7.21377.19.js:1
    run https://localhost:5001/_framework/dotnet.6.0.0-preview.7.21377.19.js:1
    runCaller https://localhost:5001/_framework/dotnet.6.0.0-preview.7.21377.19.js:1
    removeRunDependency https://localhost:5001/_framework/dotnet.6.0.0-preview.7.21377.19.js:1
    onmessage blob:https://localhost:5001/65ddd4df-7800-4bcd-87e3-c2164e3ffdda:114
Init method [BlazorWorker.WorkerBackgroundService]BlazorWorker.WorkerBackgroundService.WorkerInstanceManager:Init failed ReferenceError: showErrorNotification is not defined 65ddd4df-7800-4bcd-87e3-c2164e3ffdda:28:25
    onReady blob:https://localhost:5001/65ddd4df-7800-4bcd-87e3-c2164e3ffdda:28
    onmessage blob:https://localhost:5001/65ddd4df-7800-4bcd-87e3-c2164e3ffdda:134
    callRuntimeCallbacks https://localhost:5001/_framework/dotnet.6.0.0-preview.7.21377.19.js:1
    postRun https://localhost:5001/_framework/dotnet.6.0.0-preview.7.21377.19.js:1
    doRun https://localhost:5001/_framework/dotnet.6.0.0-preview.7.21377.19.js:1
    run https://localhost:5001/_framework/dotnet.6.0.0-preview.7.21377.19.js:1
    runCaller https://localhost:5001/_framework/dotnet.6.0.0-preview.7.21377.19.js:1
    removeRunDependency https://localhost:5001/_framework/dotnet.6.0.0-preview.7.21377.19.js:1
    onmessage blob:https://localhost:5001/65ddd4df-7800-4bcd-87e3-c2164e3ffdda:114

ReferenceError: showErrorNotification is not defined 65ddd4df-7800-4bcd-87e3-c2164e3ffdda:71:13

"System.ArgumentNullException: Value cannot be null" in WorkerInstanceManager.RegisterEvent

Originally posted by @Tewr in #28 (comment):

@andersson09 I dont think this is related, more likely is that the worker process does not have the type TEvent (as in EventHandler<TEvent>) loaded in memory. Please open a new issue if you want to discuss this further. I think an error message might be missing here in any case.

I'm running into the same problem when I use a custom event argument type (an enum I've defined). I suspect the cause is here:

EventHandlerTypeArg = typeof(TResult).FullName,

Type.GetType requires an assembly-qualified name when the type is defined anywhere except mscorlib or the current assembly (i.e., BlazorWorker.WorkerBackgroundService.dll), but EventHandlerTypeArg doesn't include the assembly name.

Exception: Unable to find compatible constructor for activating type 'My.WorkerStartup'.

When you do not register a type for the constructor of the Worker Startup class, you get an unclear error, even with WorkerOptions.Debug set to true.

It would be helpful if the error displayed the parameter that wasn't able to be resolved.

Additionally, in this case it was IConfiguration that was being injected. It would be great if the registrations from the WebAssemblyHostBuilder.CreateDefault were automatically included for you they aren't configured manually.

Source of exception:

throw new InvalidOperationException($"Unable to find compatible constructor for activating type '{type}'.");

CreateBackgroundServiceAsync results in exception saying System.Private.DataContractSerialization.resources can't be found...

Hi - I'm trying to port your implementation of the IndexedDBManager service so I can use JSStore instead. Right now I'm just hacking over the source for your original implementation in Demo.IoCExample. When I get to this line:

        myIocIndexedDbService = await startupService.CreateBackgroundServiceAsync(startup => startup.Resolve<MyIndexDBService>());

I get this exception in the console

BlazorWorker.WorkerCore.SimpleInstanceService.SimpleInstanceService: 'System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' is requesting missing assembly 'System.Private.DataContractSerialization.resources, Version=5.0.0.0, Culture=en-CA, PublicKeyToken=null')

and this as the output:

08:46:58:973 Creating background service Startup class... 08:47:01:437 Background service created in 455ms 08:47:01:438 Resolving instance... Error = System.Exception: Exception has been thrown by the target of an invocation. ---> System.Exception: Unable to resolve service for type 'Forge.DBManager.JSStore.IndexedDBManager' while attempting to activate 'Forge.DBManager.JSStore.Services.MyIndexDBService'. at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type serviceType, Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(ResultCache lifetime, Type serviceType, Type implementationType, CallSiteChain callSiteChain) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(ServiceDescriptor descriptor, Type serviceType, CallSiteChain callSiteChain, Int32 slot) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(Type serviceType, CallSiteChain callSiteChain) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite(Type serviceType, CallSiteChain callSiteChain) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.<>c__DisplayClass7_0.b__0(Type type) at System.Collections.Concurrent.ConcurrentDictionary2[[System.Type, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCallSite, Microsoft.Extensions.DependencyInjection, Version=5.0.0.1, Culture=neutral, PublicKeyToken=adb9793829ddae60]].GetOrAdd(Type key, Func2 valueFactory) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite(Type serviceType, CallSiteChain callSiteChain) at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.CreateServiceAccessor(Type serviceType) at System.Collections.Concurrent.ConcurrentDictionary2[[System.Type, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Func2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope, Microsoft.Extensions.DependencyInjection, Version=5.0.0.1, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].GetOrAdd(Type key, Func2 valueFactory) at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope) at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[MyIndexDBService](IServiceProvider provider) at Forge.DBManager.JSStore.Services.MyIndexDBServiceStartup.ResolveMyIndexDBService at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) --- End of inner exception stack trace --- at BlazorWorker.BackgroundServiceFactory.WorkerBackgroundServiceProxy1.d__301[[Forge.DBManager.JSStore.Services.MyIndexDBServiceStartup, Forge.DBManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Forge.DBManager.JSStore.Services.MyIndexDBService, Forge.DBManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() at BlazorWorker.BackgroundServiceFactory.WorkerBackgroundServiceExtensions.d__32[[Forge.DBManager.JSStore.Services.MyIndexDBServiceStartup, Forge.DBManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Forge.DBManager.JSStore.Services.MyIndexDBService, Forge.DBManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() at Forge.Pages.Counter.OnInitializedAsync() in c:\git\Forge\Forge\Pages\Counter.razor:line 108

I'll confess I'm stumped. Full source of the page I'm having trouble with is below - if you need more of the code I'm happy to share to try to get to the bottom of this.

@using BlazorWorker.BackgroundServiceFactory
@using BlazorWorker.Core
@using BlazorWorker.Core.CoreInstanceService
@using BlazorWorker.WorkerBackgroundService
@using Forge.Services
@using Forge.DBManager.JSStore.Services
@using Forge.DBManager.JSStore
@using BlazorWorker.Extensions.JSRuntime
@Inject IWorkerFactory workerFactory
@Inject IWorkerFactory dbWorkerFactory
@Inject JSStoreManager indexedDBManager

@page "/counter"

Counter
Current count: @currentCount

<button class="btn btn-primary" @OnClick="OnClick" disabled="@result.Equals("Calculating....")">@(result.Equals("Calculating....") ? "Can't touch this" : "Click me")

@Result

@status

@output
@code
{
#region start hacking in IndexedDB stuff
string output = "";
IWorker dbWorker;
IWorkerBackgroundService startupService;
string canDisposeWorker => dbWorker == null ? null : "disabled";
string RunDisabled => Running ? "disabled" : null;
bool Running = false;
#endregion

#region OC
private int currentCount = 0;
object result = "";
IWorker worker;
ICoreInstanceService backgroundService;
IInstanceHandle service;
bool Initialized = false;
#endregion
private void IncrementCount()
{
currentCount++;
}
string status;
protected override async Task OnInitializedAsync()
{
if (!Initialized)
{
Console.WriteLine("Initializing Counter page");
worker = await workerFactory.CreateAsync();
worker.IncomingMessage += UpdateStatus;
// Create service reference. For most scenarios, it's safe (and best) to keep this
// reference around somewhere to avoid the startup cost.
backgroundService = worker.CreateCoreInstanceService();
service = await backgroundService.CreateInstance();
Initialized = true;
DateTime traceTime = DateTime.Now;
#region IndexedDB startup
Running = true;
//output = "";
var rn = Environment.NewLine;
try
{
Console.WriteLine("Starting to initialize dbmanager");
if (dbWorker == null)
{
dbWorker = await dbWorkerFactory.CreateAsync();
}

        IWorkerBackgroundService<MyIndexDBService> myIocIndexedDbService;

#if NET5_0
Console.WriteLine("I'm a NET5 boy!");
#endif
var serviceCollectionDependencies = new string[] {
"Microsoft.Extensions.DependencyInjection.Abstractions.dll"
#if NET5_0
,"System.Diagnostics.Tracing.dll"
#endif
};

        if (startupService == null)
        {
            output = $"{rn}{LogDate()} Creating background service Startup class...";
            await InvokeAsync(StateHasChanged);

            traceTime = DateTime.Now;
            startupService = await dbWorker.CreateBackgroundServiceAsync<MyIndexDBServiceStartup>(wo =>
                wo.AddConventionalAssemblyOfService()
                    .AddAssemblyOf<Microsoft.Extensions.DependencyInjection.ServiceCollection>()
                    .AddAssemblies(serviceCollectionDependencies)
                    .AddBlazorWorkerJsRuntime()
                );

            output += $"{rn}{LogDate()} Background service created in {(DateTime.Now - traceTime ).Milliseconds}ms";
            await InvokeAsync(StateHasChanged);

        }

        output += $"{rn}{LogDate()} Resolving instance...";
        StateHasChanged();
        myIocIndexedDbService = await startupService.CreateBackgroundServiceAsync(startup => startup.Resolve<MyIndexDBService>());


        await using (myIocIndexedDbService)
        {
            long id;
            var storeName = indexedDBManager.Stores[0].Name;
            output += $"{rn}{LogDate()} Retrieving test person from store '{storeName}'...";
            await InvokeAsync(StateHasChanged);
            var testPerson = (await this.indexedDBManager.GetRecords<Person>(storeName)).FirstOrDefault();
            if (testPerson == null)
            {
                output += $"{rn}{LogDate()} No test person present, creating a test person...";
                await InvokeAsync(StateHasChanged);

                await this.indexedDBManager.AddRecord<Person>(
                    new StoreRecord<Person>()
                    {
                        Storename = storeName,
                        Data = new Person() { Name = "Morgoff" }
                    });

                output += $"{rn}{LogDate()} Test person record added. Verifying that it can be retrieved on the main thread...";
                await InvokeAsync(StateHasChanged);
                testPerson = (await this.indexedDBManager.GetRecords<Person>(storeName)).FirstOrDefault();
                output += $"{rn}{LogDate()} Retrieved = {testPerson?.Name ?? "N/A" }";
                await InvokeAsync(StateHasChanged);

            }
            else
            {
                output += $"{rn}{LogDate()} Test person present.";

                await InvokeAsync(StateHasChanged);
            }

            id = testPerson.Id.Value;

            output += $"{rn}{LogDate()} Trying to to get the name of the test person using the worker...";
            await InvokeAsync(StateHasChanged);
            output += $"{rn}{LogDate()} PersonName() = {await myIocIndexedDbService.RunAsync(s => s.GetPersonName(id))}";
        }

        StateHasChanged();

    }
    catch (Exception e)
    {
        output += $"{rn}Error = {e}";
        await InvokeAsync(StateHasChanged);
    }
    finally
    {
        Running = false;
    }

#endregion
}
base.OnInitializedAsync();
}
public async Task OnClick(EventArgs e)
{
result = "Calculating....";
int parameterValue = new Random().Next(200);

// Reference that live outside of the current scope should not be passed into the expression.
// To circumvent this, create a scope-local variable like this, and pass the local variable.
var localParameterValue = parameterValue;
await worker.PostMessageAsync($"Iterations:{parameterValue}");
//result = await service.RunAsync(s => s.Execute(localParameterValue));

}

private async void UpdateStatus(object sender, string message)
{
if (message.StartsWith("Progress"))
{
status = message.Split(":")[1];
result = "Calculating....";
}
else
{
result = message.Split(":")[1];
}
StateHasChanged();
}
private string LogDate()
{
return DateTime.Now.ToString("HH:mm:ss:fff");
}
}

Managing App State with Service Workers in Blazor WASM

Hi there!

I was directed to this package from a Reddit thread (https://www.reddit.com/r/Blazor/comments/ndpd6s/how_to_persist_state_across_multiple_browser_tabs/) to manage state between browser tabs. Essentially, I have a Blazor WASM application (.NET Core Hosted) in which I'd like to open a new tab/window but persist the data to the new page. Is this possible with Service Workers? I know this is possible natively with Blazor Server but I need to use Blazor WASM for the client.

Use Case: Load Customer on main page -> Open customer history in new window -> Customer History displayed. Currently, the app "resets" and when opening a new tab/window it is treated as a new application.

Any insight into this would be much appreciated!

Http call inside a worker service

Is it possible to make an http request inside the worker service? It seems the worker service can't get created if I put a HttpClient property in it, although I don't see any error messages anywhere. I tried to explicitly pull in System.Net.Http.dll with worker init options but still it's failing silently.

Blazorworker requesting missing assembly

The blazorworker is requesting missing assembly Microsoft.AspNetCore.Components, Version=3.1.8.0 but I have that NuGet package installed. Interestingly, when installing version 3.1.9.0 the error changes to the same but lists the missing assembly as 3.1.9.0. How can I provide the blazorworker with this assembly?

Switching pages while waiting for task to finish

User jdcrutchley sends the following message to the owners of Package 'Tewr.BlazorWorker.BackgroundService 1.3.0'.

I'm looking to do something strange with Blazor, and was wondering if your BlazorWorker project might help me. I want to start a long set of API interactions that could take several minutes, but allow the user to switch pages and then come back and see progress or maybe a "finished" message if it is done. If I navigate away from my page and don't have a cancellation token set up, the async process continues in the background, but I don't know how to "hook back up" to it from the front end when the page reloads. Is this a use case that BlazorWorker could help with, or am I barking up the wrong tree?

Thanks.

jdc

Typing to create a generic typed component, but having an issue getting WASM-WORKER to recognise my types

Hey there,

Thanks for making this threading/web-worker library, its very useful.

I am trying to make a generic component that lets me use the library in an easier way. I thought some of the things were still somewhat "low level" and I was hoping I could abstract some things even more, so that basically I can have threaded components in 1 or 2 lines of code.

The PICalculator example is nice, though it just relies on simple types (ints, strings, etc) - So as a POC I'm making one with datacontacts where I wrapped the input, output, and state of the PICalculator into a datacontract models

So first of I created an interface, looking like below - an interface with a request and a response, and an intermediate state update

    public interface IWorkerService<in TRequest, TResponse, TState>
    {
        public event EventHandler<TState> StateUpdate;
        Task<TResponse> DoWork(TRequest request);
    }

After that I created the generic component, looking like this:

using System;
using System.Threading.Tasks;
using BlazorWorker.BackgroundServiceFactory;
using BlazorWorker.Core;
using BlazorWorker.TypedDemo.DataContracts;
using BlazorWorker.TypedDemo.Shared;
using BlazorWorker.WorkerBackgroundService;
using BlazorWorker.WorkerCore;
using Microsoft.AspNetCore.Components;

namespace BlazorWorker.TypedDemo.Core
{
    public class WorkerComponent<TRequest, TResponse, TState, TService> : ComponentBase, IAsyncDisposable where TService : class, IWorkerService<TRequest, TResponse, TState>
    {
        [Inject] private IWorkerFactory WorkerFactory { get; set; }

        protected TState CurrentState;
        protected TResponse Response;
        protected IWorker Worker;
        protected IWorkerBackgroundService<TService> BackgroundService;

        protected bool RunDisabled => Running;
        protected bool Running = false;

        public async Task<TResponse> DoWork(TRequest request)
        {
            Running = true;
            try
            {
                if (Worker == null)
                {
                    Worker = await WorkerFactory.CreateAsync();
                }

                if (BackgroundService == null)
                {

                    StateHasChanged();

                    WebWorkerOptions.Init(null, new TypeAwareSerializeLinqExpressionSerializer(typeof(PIRequest), typeof(PIResponse)));
                    {

                    };

                    BackgroundService = await Worker.CreateBackgroundServiceAsync<TService>(options => options.AddAssemblies("BlazorWorker.TypedDemo.Core.dll", "BlazorWorker.TypedDemo.Shared.dll", "BlazorWorker.TypedDemo.DataContracts.dll"));

                    await BackgroundService.RegisterEventListenerAsync("StateUpdate",
                            (object s, TState pinum) =>
                            {
                                CurrentState = pinum;
                                StateHasChanged();
                            });

                    StateHasChanged();
                }

                Response = await BackgroundService.RunAsync(s => s.DoWork(request));

                StateHasChanged();

                return Response;

            }
            catch (Exception e)
            {
                ExceptionState = e;
                StateHasChanged();
            }
            finally
            {
                Running = false;
            }

            return default;
        }

        public Exception ExceptionState { get; set; }

        public async ValueTask DisposeAsync()
        {
            if (BackgroundService != null)
            {
                await BackgroundService.DisposeAsync();
                BackgroundService = null;
            }

            if (Worker != null)
            {
                await Worker.DisposeAsync();
                Worker = null;
            }
        }
    }
}

Which, when creating a PICalculator component, would be used like this:

    public class BackgroundServiceTypedComponent : WorkerComponent<PIRequest, PIResponse, string, TypedMathsService>
    {
        public string TextValue { get; set; }

        public string Output
        {
            get
            {
                return ExceptionState?.Message + CurrentState + Response?.Result.ToString(CultureInfo.InvariantCulture);
            }
        }

        public int piIterations { get; set; } = 1;

        protected async Task OnClick(EventArgs arg)
        {
            var length = int.Parse(TextValue);
            piIterations = length;

            DoWork(new PIRequest() { Lenght = length });
        }
}

So as you can see, having the WorkerComponent abstracts all the threading logic from the actual PICalculation logic, and you can re-use this component for other long-running operations that can report states in between.

Now, the first issue I was having, was (without changing anything to the core project) - was that the dotnet side was already throwing an exception, telling me:

Error converting type: Type 'BlazorWorker.TypedDemo.Shared.PIRequest' with data contract name 'PIRequest:http://schemas.datacontract.org/2004/07/BlazorWorker.TypedDemo.Shared' is not expected. 

Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.

So, as you can see in the WorkerComponent I posted above, after debugging for a while I figured out the issue,
So, somewhat hacky but for now I turned the WebWorkerOptions into a singleton (First I want the POC to work, then I'll clean it up) :

                    WebWorkerOptions.Init(null, new TypeAwareSerializeLinqExpressionSerializer(typeof(PIRequest), typeof(PIResponse)));
                    {

                    };

The only difference in the TypeAwareSerializeLinqExpressionSerializer is that it's an IExpressionSerializer which for all types does serializer.AddKnownTypes(types);

This solves the first error.

However, now when I'm running my project and calling the function, I'm getting this exception:

Worker exception: One or more errors occurred. (One or more errors occurred.)
WASM-WORKER: BlazorWorker.WorkerBackgroundService.WorkerInstanceManager.PostMessage(): 
{"ResultPayload":null,"IsException":true,"Exception":{"ClassName":"System.AggregateException","Message":"One or more errors occurred.","Data":null,"InnerException":{"ClassName":"System.Runtime.Serialization.SerializationException","Message":"Element ':Value' contains data of the 'http://schemas.datacontract.org/2004/07/BlazorWorker.TypedDemo.Shared:PIRequest' data contract. 
The deserializer has no knowledge of any type that maps to this contract. Add the type corresponding to 'PIRequest' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to DataContractSerializer.","Data":null,"InnerException":null,"HelpURL":null,"StackTraceString":"  
at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize (System.Runtime.Serialization.XmlReaderDelegator reader, System.String name, System.String ns, System.Type declaredType, System.Runtime.Serialization.DataContract& dataContract) <0x2bf1eb0 + 0x00132> in <filename unknown>:0 
  at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize (System.Runtime.Serialization.XmlReaderDelegator xmlReader, System.Int32 id, System.RuntimeTypeHandle declaredTypeHandle, System.String name, System.String ns) <0x2c7e6c8 + 0x0004e> in <filename unknown>:0 
  at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserialize (System.Runtime.Serialization.XmlReaderDelegator xmlReader, System.Int32 declaredTypeID, System.RuntimeTypeHandle declaredTypeHandle, System.String name, System.String ns) <0x2c7e578 + 0x0002e> in <filename unknown>:0 
  at System.Runtime.Serialization.Json.JsonFormatReaderInterpreter.InternalDeserialize (System.Type type, System.String name) <0x2c7e3c0 + 0x0007a> in <filename unknown>:0 
  at System.Runtime.Serialization.Json.JsonFormatReaderInterpreter.ReadValue (System.Type type, System.String name) <0x2c7dd38 + 0x0031a> in <filename unknown>:0 
  at System.Runtime.Serialization.Json.JsonFormatReaderInterpreter.ReadMembers (System.Int32 index, System.Runtime.Serialization.ClassDataContract classContract, System.Runtime.Serialization.BitFlagsGenerator expectedElements, System.Int32& memberIndex) <0x2c7d888 + 0x00194> in <filename unknown>:0 
  at System.Runtime.Serialization.Json.JsonFormatReaderInterpreter.ReadMembers (System.Runtime.Serialization.ClassDataContract classContract, System.Runtime.Serialization.ExtensionDataObject extensionData) <0x2c6cb50 + 0x000b4> in <filename unknown>:0 
  at System.Runtime.Serialization.Json.JsonFormatReaderInterpreter.ReadClass (System.Runtime.Serialization.ClassDataContract classContract) <0x2c6c510 + 0x000b4> in <filename unknown>:0 
  at System.Runtime.Serialization.Json.JsonFormatReaderInterpreter.ReadFromJson (System.Runtime.Serialization.XmlReaderDelegator xmlReader, System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson context, System.Xml.XmlDictionaryString emptyDictionaryString, System.Xml.XmlDictionaryString[] memberNames) <0x2c71708 + 0x00086> in <filename unknown>:0 
  at System.Runtime.Serialization.Json.JsonFormatReaderGenerator+CriticalHelper+<>c__DisplayClass0_0.<GenerateClassReader>b__0 (System.Runtime.Serialization.XmlReaderDelegator xr, System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson ctx, System.Xml.XmlDictionaryString emptyDictionaryString, System.Xml.XmlDictionaryString[] memberNames) <0x2c71128 + 0x00022> in <filename unknown>:0 
  at System.Runtime.Serialization.Json.JsonClassDataContract.ReadJsonValueCore (System.Runtime.Serialization.XmlReaderDelegator jsonReader, System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson context) <0x2c70138 + 0x00040> in <filename unknown>:0 
  at System.Runtime.Serialization.Json.JsonDataContract.ReadJsonValue (System.Runtime.Serialization.XmlReaderDelegator jsonReader, System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson context) <0x2c6fd78 + 0x0001a> in <filename unknown>:0 
  at System.Runtime.Serialization.Json.DataContractJsonSerializer.ReadJsonValue (System.Runtime.Serialization.DataContract contract, System.Runtime.Serialization.XmlReaderDelegator reader, System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson context) <0x2c66c10 + 0x00016> in <filename unknown>:0 
  at System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson.ReadDataContractValue (System.Runtime.Serialization.DataContract dataContract, System.Runtime.Serialization.XmlReaderDelegator reader) <0x2c66ad0 + 0x0000a> in <filename unknown>:0 
  at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize (System.Runtime.Serialization.XmlReaderDelegator reader, System.String name, System.String ns, System.Type declaredType, System.Runtime.Serialization.DataContract& dataContract) <0x2bf1eb0 + 0x00380> i

Now I'm guessing that somewhere on the WASM-WORKER side I also have to register the known-types somewhere... But I've been debugging through the code and trying a bunch of different things, and so far I've been unable to find where inside the WASM-WORKER I can possibly register my datacontracts.

I have forked the project, and commited a "working" example over here: https://github.com/RonSijm/BlazorWorker - that is getting to the point of throwing the Worker exception.

Sorry for the long post, I was hoping you could possibly help my with this, maybe you have an idea on how to solve this. If you have any insights, that'd be great.. thanks!

question, help request

hi
I used BlazorWorker and having some of bugs
for example I have bugs on load assemblys which are a lot of and I shouldn't list that in code
and also if I list that then webworker cant find that because the file not exist
other problem is performance issue when return huge of data, for example 10 mega bytes byte array waiting much time
so I decided to make other webworker for my project because of different approach and different vision of this project
however now I have few problem in load assembly and interrupt a method via JavaScript
my question is how can I load the app in web worker and is any document exist for read?

also I read this file which generated for webworker but this have extra things which I don't understand

self.onmessage = function () {
    const initConf = JSON.parse('{"appRoot":"http://localhost:59244","DependentAssemblyFilenames":["BlazorWorker.WorkerCore.dll","netstandard.dll","mscorlib.dll","System.dll","System.Core.dll","System.Buffers.dll","System.Collections.dll","System.Configuration.dll","System.Console.dll","System.Diagnostics.Debug.dll","System.Diagnostics.DiagnosticSource.dll","System.Diagnostics.StackTrace.dll","System.Diagnostics.TraceSource.dll","System.Dynamic.Runtime.dll","System.Globalization.Calendars.dll","System.Globalization.Extensions.dll","System.Globalization.dll","System.Linq.Expressions.dll","System.Linq.Queryable.dll","System.Linq.dll","System.Memory.dll","System.Numerics.Vectors.dll","System.Numerics.dll","System.ObjectModel.dll","System.Private.CoreLib.dll","System.Private.Runtime.InteropServices.JavaScript.dll","System.Private.Uri.dll","System.Private.Xml.Linq.dll","System.Private.Xml.dll","System.Reflection.DispatchProxy.dll","System.Reflection.Extensions.dll","System.Reflection.Metadata.dll","System.Reflection.Primitives.dll","System.Reflection.TypeExtensions.dll","System.Reflection.dll","System.Runtime.Extensions.dll","System.Runtime.Handles.dll","System.Runtime.InteropServices.RuntimeInformation.dll","System.Runtime.InteropServices.dll","System.Runtime.Intrinsics.dll","System.Runtime.Loader.dll","System.Runtime.Numerics.dll","System.Runtime.dll","System.Threading.Tasks.dll","System.Threading.Thread.dll","System.Threading.dll","BlazorWorker.WorkerBackgroundService.dll","Newtonsoft.Json.dll","System.Xml.dll","Serialize.Linq.dll","System.Data.dll","System.Runtime.CompilerServices.Unsafe.dll","System.Runtime.Serialization.dll","System.Threading.Tasks.Extensions.dll","System.Xml.ReaderWriter.dll","System.Text.RegularExpressions.dll","System.Collections.Concurrent.dll","System.ComponentModel.Primitives.dll","System.ComponentModel.TypeConverter.dll","System.ComponentModel.dll","System.Collections.Immutable.dll","System.Collections.NonGeneric.dll","System.Collections.Specialized.dll","System.Data.Common.dll","System.Data.DataSetExtensions.dll","System.Reflection.Emit.ILGeneration.dll","System.Reflection.Emit.Lightweight.dll","System.Private.DataContractSerialization.dll","System.Runtime.Serialization.Formatters.dll","System.Runtime.Serialization.Json.dll","System.Runtime.Serialization.Primitives.dll","System.Runtime.Serialization.Xml.dll","System.Text.Encoding.CodePages.dll","System.Text.Encoding.Extensions.dll","System.Text.Encoding.dll","Monsajem_incs.dll","BlazorApp_NetCore.dll","System.CodeDom"],"deploy_prefix":"_framework","MessageEndPoint":"[BlazorWorker.WorkerCore]BlazorWorker.WorkerCore.MessageService:OnMessage","InitEndPoint":"[BlazorWorker.WorkerBackgroundService]BlazorWorker.WorkerBackgroundService.WorkerInstanceManager:Init","wasmRoot":"_framework","blazorBoot":"_framework/blazor.boot.json","debug":false}');
    const nonExistingDlls = [];
    let blazorBootManifest = {
        resources: { assembly: { 'AssemblyName.dll': 'sha256-<sha256>' } }
    };
    const onReady = () => {
        const messageHandler =
            Module.mono_bind_static_method(initConf.MessageEndPoint);
        // Future messages goes directly to the message handler
        self.onmessage = msg => {
            messageHandler(msg.data);
        };

        if (!initConf.InitEndPoint) {
            return;
        }

        try {
            Module.mono_call_static_method(initConf.InitEndPoint, []);
        } catch (e) {
            console.error(`Init method ${initConf.InitEndPoint} failed`, e);
            throw e;
        }
    };

    const onError = (err) => {
        console.error(err);
    };

    function asyncLoad(url, reponseType) {
        return new Promise((resolve, reject) => {
            const xhr = new XMLHttpRequest();
            const arrayBufferType = 'arraybuffer';
            xhr.open('GET', url, /* async: */ true);
            xhr.responseType = reponseType || arrayBufferType;
            xhr.onload = function xhr_onload() {
                if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
                    if (this.responseType === arrayBufferType) {
                        const asm = new Uint8Array(xhr.response);
                        resolve(asm);
                    } else {
                        resolve(xhr.response);
                    }
                } else {
                    reject(xhr);
                }
            };
            xhr.onerror = reject;
            xhr.send(undefined);
        });
    }

    var config = {};
    var Module = {};

    const wasmBinaryFile = `${initConf.appRoot}/${initConf.wasmRoot}/dotnet.wasm`;
    const suppressMessages = ['DEBUGGING ENABLED'];
    const appBinDirName = 'appBinDir';

    Module.print = line => (suppressMessages.indexOf(line) < 0 && console.log(`WASM-WORKER: ${line}`));

    Module.printErr = line => {
        console.error(`WASM-WORKER: ${line}`);
        showErrorNotification();
    };
    Module.preRun = [];
    Module.postRun = [];
    Module.preloadPlugins = [];

    Module.locateFile = fileName => {
        switch (fileName) {
            case 'dotnet.wasm': return wasmBinaryFile;
            default: return fileName;
        }
    };

    Module.preRun.push(() => {
        const mono_wasm_add_assembly = Module.cwrap('mono_wasm_add_assembly', null, [
            'string',
            'number',
            'number',
        ]);

        mono_string_get_utf8 = Module.cwrap('mono_wasm_string_get_utf8', 'number', ['number']);

        MONO.loaded_files = [];
        var baseUrl = `${initConf.appRoot}/${initConf.deploy_prefix}`;

        initConf.DependentAssemblyFilenames.forEach(url => {

            if (!blazorBootManifest.resources.assembly.hasOwnProperty(url)) {
                //Do not attempt to load a dll which is not present anyway
                nonExistingDlls.push(url);
                return;
            }

            const runDependencyId = `blazor:${url}`;
            addRunDependency(runDependencyId);

            asyncLoad(baseUrl + '/' + url).then(
                data => {
                    const heapAddress = Module._malloc(data.length);
                    const heapMemory = new Uint8Array(Module.HEAPU8.buffer, heapAddress, data.length);
                    heapMemory.set(data);
                    mono_wasm_add_assembly(url, heapAddress, data.length);
                    MONO.loaded_files.push(url);
                    removeRunDependency(runDependencyId);
                },
                errorInfo => {
                    const isPdb404 = errorInfo instanceof XMLHttpRequest
                        && errorInfo.status === 404
                        && url.match(/\.pdb$/);
                    if (!isPdb404) {
                        onError(errorInfo);
                    }
                    removeRunDependency(runDependencyId);
                }
            );
        });
    });

    Module.postRun.push(() => {
        MONO.mono_wasm_setenv('MONO_URI_DOTNETRELATIVEORABSOLUTE', 'true');
        const load_runtime = Module.cwrap('mono_wasm_load_runtime', null, ['string', 'number']);
        load_runtime(appBinDirName, 0);
        MONO.mono_wasm_runtime_is_ready = true;
        onReady();
        if (initConf.debug && nonExistingDlls.length > 0) {
            console.warn(`BlazorWorker: Module.postRun: ${nonExistingDlls.length} assemblies was specified as a dependency for the worker but was not present in the bootloader. This may be normal if trimmming is used. To remove this warning, either configure the linker not to trim the specified assemblies if they were removed in error, or conditionally remove the specified dependencies for builds that uses trimming. If trimming is not used, make sure that the assembly is included in the build.`, nonExistingDlls);
        }
    });

    config.file_list = [];

    global = globalThis;
    self.Module = Module;

    //TODO: This call could/should be session cached. But will the built-in blazor fetch service worker override 
    // (PWA et al) do this already if configured ?
    asyncLoad(`${initConf.appRoot}/${initConf.blazorBoot}`, 'json')
        .then(blazorboot => {
            blazorBootManifest = blazorboot;
            let dotnetjsfilename = '';
            const runttimeSection = blazorboot.resources.runtime;
            for (var p in runttimeSection) {
                if (Object.prototype.hasOwnProperty.call(runttimeSection, p) && p.endsWith('.js')) {
                    dotnetjsfilename = p;
                }
            }

            if (dotnetjsfilename === '') {
                throw 'BlazorWorker: Unable to locate dotnetjs file in blazor boot config.';
            }

            self.importScripts(`${initConf.appRoot}/${initConf.wasmRoot}/${dotnetjsfilename}`);

        }, errorInfo => onError(errorInfo));
}()

how to disable message output in F12

large byte[] to trans, many large string output in debug window(F12), how to disable it , or config to disable output

Console.WriteLine($"{nameof(InjectableMessageService)}.{nameof(PostMessageAsync)}('{message}')"); // how to disable
impleInstanceServiceProxy.class and InjectableMessageService.PostMessageAsync.class

integrity problem in published version net5.0

(index):1 Failed to find a valid digest in the 'integrity' attribute for resource 'http://**********/_framework/Serialize.Linq.dll' with computed SHA-256 integrity 'VsDG9v5hAIf37tRPnT1Nqbu2cE9gPYyP5czUixcnYl8='. The resource has been blocked.

Sometimes the Newtonsoft.Json has the same error.

Environment: WASM, host by httpsys as a windows service.
Only encountered in published version,

It's an old problem. I solve this problem by using the source code of this project. Change the targetframework to net5.0, and clean the solution, delete all the bin and obj directories. Update all the package. It works every time. Maybe it's the blazor problem. Before Blazor fix it, How about separate this project into net2.1 and net5.0 temporarily.

Serialization error with IoC and starting a worker

Is there a way to access the IJSRuntime in a Worker Startup class?

I'm looking to use ILogger with WebAssemblyConsoleLogger to support my shared services to run in background workers.

WebAssemblyConsoleLogger is internal but I've copied it into my project and I noticed the implementation uses InvokeVoid versus IJSRuntime.InvokeVoidAsync.

I really just need to write to the browser's console. I did see there is a DOMObject.Self which is also internal to the BlazorWorker JSRuntime assembly. Perhaps there is a way I'm not seeing?

Share data with web worker

I wonder if I can share data with worker process.
Option 1: Use raw json serialized string, too frequent postmessage
Option2: Use browser storage, avaliable, but not for big object
Option3: Use indexDB, with nutget, and JSRuntime injection support
Option4: Use distribute cache service, like redis, ncache, but I prefer build-in memory distribute cache, but in that case, worker need an access to registered service in app instance, or just the instance can be pass to worker(not sure how distribure memory cache instance be managed).Mainly I'm working on WASM. The server does not need to access the processing data.

It's faster if I can use memory cache to buffer the file stream in bucks queque, the worker read the stream bucks and upload asynchronously

Any way, the final goal is to use web worker asynchronously upload large file to outside web api.I can do that within the app process use async hronous function without blocking the UI, until the the fetch function invkoed. I inspected the browser performance profile, the fetch function blocked ui, and I can do nothing about it.Httpclient async function use fetch internally, not really async in WASM.

Is it possible to terminate long running process?

Hi,
I have a long running task in an external dll, which takes more than 30 secs to complete. We track the UI changes while the task is running and need to terminate the running task if the input values changed, and start the task again with the new values. Tried calling the DisposeAsync method but it seems to be not working as we needed. Is there a better way to achieve this using BlazorWorker? Thank you!

await backgroundService.DisposeAsync(); await worker.DisposeAsync();

Add native support for CancellationToken

Also an extension method CancellationToken.ThrowIfCancellationRequestedAsync() which would call CancellationToken.ThrowIfCancellationRequested after having called Task.Delay(1), to allow for Context switch to read incoming requests for cancellation

Log / throw exception when missing third-party dlls

As discussed in #17.

Some of the time, the loading of a service instance will fail silently if the necessary dlls are not loaded.

We would expect at least a console error message, and ideally an exception bubbling up to the caller rather than stalling the init.

Any nuget-released planned including environment variable for culture?

Current nuget (3.1.0) doesn't include the possiblity to set web-worker environment variables like culture.
Issue: #67
This is a problem when needing to correctly format dates etc.
Since .NET 7 Threading support is still some time in the future this project is the only good option to use web-workers for more complex stuff using C#. Do you plan to do a new nuget-release anytime soon?

Excellent work by the way!

/Best Regards
"Matt"

SerializeLinqExpressionSerializer.cs - no matching element

Using the latest release I'm getting an error when attempting to instantiate the worker through RunAsync:

var service = await worker.CreateBackgroundServiceAsync<DataLoader>(
                              options => options
                              .AddAssemblies("IMS36.dll", "IMS36.Shared.dll", "System.Net.Http.dll", "System.Net.Primitives.dll", "System.Security.Cryptography.X509Certificates.dll",
                              "System.Diagnostics.Tracing.dll", "Microsoft.Extensions.DependencyInjection.dll").AddHttpClient()
                          );

var result = await service.RunAsync(s => s.UpdateAllTablesAsync(_state,""));

The worker:
public async Task<ManifestBox<State>> UpdateAllTablesAsync(State _state, string table = "") {

Console:

3e8d9e9d-515f-4de4-b444-0c9b87f230c8:66 WASM-WORKER: BlazorWorker.WorkerBackgroundService.WorkerInstanceManager.PostMessage(): {"MessageType":"InitWorkerComplete"}.
13:08:18.110 3e8d9e9d-515f-4de4-b444-0c9b87f230c8:66 WASM-WORKER: BlazorWorker.WorkerBackgroundService.WorkerInstanceManager.Init(): Done.
13:08:18.276 blazor.webassembly.js:1 WorkerBackgroundServiceProxy.InitAsync(): 1 {"WorkerId":1,"InstanceId":1,"AssemblyName":"IMS36, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null","TypeName":"IMS36.DataLoader","CallId":1,"MessageType":"InitInstance"}
13:08:18.389 3e8d9e9d-515f-4de4-b444-0c9b87f230c8:66 WASM-WORKER: BlazorWorker.WorkerBackgroundService.WorkerInstanceManager.PostMessage(): {"CallId":1,"IsSuccess":true,"Exception":null,"MessageType":"InitInstanceComplete"}.
13:08:18.390 3e8d9e9d-515f-4de4-b444-0c9b87f230c8:66 WASM-WORKER: MessageService.OnMessage: {"WorkerId":1,"InstanceId":1,"AssemblyName":"IMS36, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null","TypeName":"IMS36.DataLoader","CallId":1,"MessageType":"InitInstance"}
blazor.webassembly.js:1 
        
       crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
      Unhandled exception rendering component: Sequence contains no matching element
System.InvalidOperationException: Sequence contains no matching element
   at System.Linq.ThrowHelper.ThrowNoMatchException()
   at System.Linq.Enumerable.Single[FieldInfo](IEnumerable`1 source, Func`2 predicate)
   at Serialize.Linq.Factories.TypeResolverNodeFactory.TryToInlineExpression(MemberExpression memberExpression, Expression& inlineExpression)
   at Serialize.Linq.Factories.TypeResolverNodeFactory.ResolveMemberExpression(MemberExpression memberExpression)
   at Serialize.Linq.Factories.TypeResolverNodeFactory.Create(Expression expression)
   at System.Linq.Enumerable.SelectIListIterator`2[[System.Linq.Expressions.Expression, System.Linq.Expressions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a],[Serialize.Linq.Nodes.ExpressionNode, Serialize.Linq, Version=1.8.1.0, Culture=neutral, PublicKeyToken=25bcc11ba213b377]].MoveNext()
   at System.Collections.Generic.List`1[[Serialize.Linq.Nodes.ExpressionNode, Serialize.Linq, Version=1.8.1.0, Culture=neutral, PublicKeyToken=25bcc11ba213b377]].InsertRange(Int32 index, IEnumerable`1 collection)
   at System.Collections.Generic.List`1[[Serialize.Linq.Nodes.ExpressionNode, Serialize.Linq, Version=1.8.1.0, Culture=neutral, PublicKeyToken=25bcc11ba213b377]].AddRange(IEnumerable`1 collection)
   at Serialize.Linq.Nodes.ExpressionNodeList..ctor(INodeFactory factory, IEnumerable`1 items)
   at Serialize.Linq.Nodes.MethodCallExpressionNode.Initialize(MethodCallExpression expression)
   at Serialize.Linq.Nodes.ExpressionNode`1[[System.Linq.Expressions.MethodCallExpression, System.Linq.Expressions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]]..ctor(INodeFactory factory, MethodCallExpression expression)
   at Serialize.Linq.Nodes.MethodCallExpressionNode..ctor(INodeFactory factory, MethodCallExpression expression)
   at Serialize.Linq.Factories.NodeFactory.Create(Expression expression)
   at Serialize.Linq.Factories.TypeResolverNodeFactory.ResolveMethodCallExpression(MethodCallExpression methodCallExpression)
   at Serialize.Linq.Factories.TypeResolverNodeFactory.Create(Expression expression)
   at Serialize.Linq.Nodes.LambdaExpressionNode.Initialize(LambdaExpression expression)
   at Serialize.Linq.Nodes.ExpressionNode`1[[System.Linq.Expressions.LambdaExpression, System.Linq.Expressions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]]..ctor(INodeFactory factory, LambdaExpression expression)
   at Serialize.Linq.Nodes.LambdaExpressionNode..ctor(INodeFactory factory, LambdaExpression expression)
   at Serialize.Linq.Factories.NodeFactory.Create(Expression expression)
   at Serialize.Linq.Factories.TypeResolverNodeFactory.Create(Expression expression)
   at Serialize.Linq.Factories.DefaultNodeFactory.Create(Expression expression)
   at Serialize.Linq.Serializers.ExpressionConverter.Convert(Expression expression, FactorySettings factorySettings)
   at Serialize.Linq.Serializers.ExpressionSerializer.SerializeText(Expression expression, FactorySettings factorySettings)
   at BlazorWorker.WorkerBackgroundService.SerializeLinqExpressionSerializer.Serialize(Expression expression) in C:\Users\microDevBox\source\repos\IMS36\BlazorWorker3.1.0\src\BlazorWorker.WorkerBackgroundService\SerializeLinqExpressionSerializer.cs:line 22
   at BlazorWorker.BackgroundServiceFactory.WorkerBackgroundServiceProxy`1.<InvokeAsyncInternal>d__45`1[[IMS36.DataLoader, IMS36, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[IMS36.Shared.Models.ManifestBox`1[[IMS36.StateContainer.State, IMS36, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], IMS36.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() in C:\Users\microDevBox\source\repos\IMS36\BlazorWorker3.1.0\src\BlazorWorker.ServiceFactory\WorkerBackgroundServiceProxy.cs:line 379
   at BlazorWorker.BackgroundServiceFactory.WorkerBackgroundServiceProxy`1.<RunAsync>d__41`1[[IMS36.DataLoader, IMS36, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[IMS36.Shared.Models.ManifestBox`1[[IMS36.StateContainer.State, IMS36, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], IMS36.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() in C:\Users\microDevBox\source\repos\IMS36\BlazorWorker3.1.0\src\BlazorWorker.ServiceFactory\WorkerBackgroundServiceProxy.cs:line 307
   at IMS36.StateDataManager.InitiateDataLoad(Int32 chunkSize, Int32 delay) in C:\Users\microDevBox\source\repos\IMS36\IMS36\State\StateDataManager.cs:line 55
   at IMS36.Shared.MainLayout.OnInitializedAsync() in C:\Users\microDevBox\source\repos\IMS36\IMS36\Shared\MainLayout.razor:line 168
   at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

How do you debug C# code executed within the worker?

Hi,

I'm using your blazorworker.js to execute C# code from javascript in a worker (without the rest of the functionality, e.g no need to use callbacks to C#, just javascript main thread <-> C# (through worker) <-> javascript. Using this approach, I noticed there's no way to debug the C# code executed by the worker itself apart from rewiring Console.WriteLine to the browser console.

I was curious to know, do you know any way to debug the C# code using the debugger in VS?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.