WhenSessionChanged似乎不能用作LocalSystem

时间:2017-09-06 09:47:26

标签: c# topshelf

我用TopShelf创建了Windows服务:

HostFactory.Run(x =>
{
    x.UseAutofacContainer(BuildScope());

    x.Service<BootstrapService>(s =>
    {
        s.ConstructUsingAutofacContainer();
        s.WhenStarted(tc => tc.Start());
        s.WhenStopped(tc => tc.Stop());
        s.WhenSessionChanged((bs, args) => bs.SessionChanged(args));
    });

    x.RunAsLocalSystem();

    x.SetDescription(CONST_Description);
    x.SetDisplayName(CONST_DisplayName);
    x.SetServiceName(CONST_ServiceName);
});

服务正在以LocalSystem身份运行。问题是,当其他用户登录windwos时,不会调用WhenSessionChanged。为什么以及如何使此回调起作用?

0 个答案:

没有答案