New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
builder.Services.AddHostedService<TimerBackgroundService>(); has no effect #41860
Comments
This seems like an issue with MauiAppBuilder. @Redth can you please help route this? |
@eerhardt I wonder if MauiAppBuilder can start using |
It isn't supported. See reasoning here: Specifically (4), which I copied here:
|
There are other ways to enable this scenario, though. One example is https://github.com/shinyorg/shiny. I've never personally used it, but my understanding is that it works well. |
Shiny looks promising, but version specific to MAUI is in alpha release, the stable ones are for Xamarin platform. |
You don't want a hosted service. ASP.NET will wait for all hosted services to start - android & ios apps cannot. What you really want is an IMauiInitializeService or yes, Shiny also has IShinyStartupTask which is similar. Both of these concepts can be found here: https://github.com/shinyorg/shiny/tree/master/src/Shiny.Hosting.Maui |
@aritchie |
Is there an existing issue for this?
Describe the bug
In a Blazor MAUI Hybrid Project.
I was trying to run a service in the background using the following command
This has no effect whatsoever, even the constructor of TimerBackgroundService does not run
All the examples i saw were for server side scenario, not sure if this is supported in Blazor wasm or Blazor Hybrid Porjects.
If it is supported, why is it not executing .
Here is the actual background service
Expected Behavior
Was expecting the TimerBackground service code to execute.
Steps To Reproduce
Add the
builder.Services.AddSingleton();
builder.Services.AddHostedService(sp => sp.GetRequiredService());
in Blazor Wasm or BlazorHyrbid Project
Exceptions (if any)
None
.NET Version
6.0.300
Anything else?
No response
The text was updated successfully, but these errors were encountered: