有没有什么方法可以在一个可执行文件中运行多个主机?Topshelf多个主机
// Create hosts
var h1 = HostFactory.New (...); var h2 = HostFactory.New (...)
// Start hosts
in one application Runner.Run (h1, h2);
编辑
解决了线程。但不知道这是否是安全的......
new Thread (()=>Runner.Run (h1));
new Thread (()=>Runner.Run (h2));
因此,这可能会导致很多问题,我不确定ServiceCoordinator是否可以像这样安全寻址,您可能会在它们之间发生串扰。此外,如果您尝试将其作为服务运行而不仅仅是控制台应用程序,则会出现奇怪的行为。我根本不会建议这种方法。如果您想了解更多创意,请加入我们的邮件列表https://groups.google.com/forum/#!forum/topshelf-discuss – Travis 2012-02-11 14:28:52