We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
比如在项目 DemoPlugin1 中添加一个自定义的 BackgroundService,目的是插件加载后就一秒输出一次当前时间,插件卸载时停止输出。
using Microsoft.Extensions.Hosting; using System; using System.Threading; using System.Threading.Tasks; namespace DemoPlugin1 { public class Class1 : BackgroundService { protected override async Task ExecuteAsync(CancellationToken stoppingToken) { while (!stoppingToken.IsCancellationRequested) { Console.WriteLine(DateTime.Now); await Task.Delay(1000); } } } }
正常的开发方式,需要在 ConfigureServices() 方法中依赖注入
public void ConfigureServices(IServiceCollection services) { services.AddHostedService<Class1>(); }
在插件中配置的 HostedService 要怎么才能运行\停止?
The text was updated successfully, but these errors were encountered:
这个示例现在暂时不支持HostService, 只支持简单的界面组件。 你的这个反馈不错,我后续把它考虑进来,写一篇 多谢支持
Sorry, something went wrong.
MethodInfo method = typeof(ServiceCollectionHostedServiceExtensions).GetMethod("AddHostedService").MakeGenericMethod(t);
lamondlu
No branches or pull requests
比如在项目 DemoPlugin1 中添加一个自定义的 BackgroundService,目的是插件加载后就一秒输出一次当前时间,插件卸载时停止输出。
正常的开发方式,需要在 ConfigureServices() 方法中依赖注入
在插件中配置的 HostedService 要怎么才能运行\停止?
The text was updated successfully, but these errors were encountered: