【发布时间】:2020-10-06 07:55:27
【问题描述】:
我有一个使用 Topshelf 在 Service Fabric 下运行的有状态服务。问题是在升级时我收到一个错误,因为当 RunAsync 方法触发 CancelationToken 时,服务没有停止(RunAsync 报告属性“RunAsyncSlowCancellation”的警告)。如何使用令牌停止服务?
public static TopshelfExitCode RunServiceHost(CancellationToken token)
{
return HostFactory.Run(x =>
{
x.Service<MyService>(s =>
{
s.ConstructUsing(name => new MyService());
s.WhenStarted((tc,a) => tc.Start(a));
s.WhenStopped((tc, a) =>tc.Stop(a));
});
});
}
【问题讨论】:
-
不相关,但我想知道您为什么决定选择 TopShelf 而不是 Worker Servies 吗? (或者这是一个旧应用程序?)
标签: .net .net-core azure-service-fabric topshelf