Topshelf multiple hosts

Is there any way in topshelf to run multiple hosts in a single executable?

// Create hosts
var h1 = HostFactory.New (...); var h2 = HostFactory.New (...)

// Start hosts
 in one application Runner.Run (h1, h2);

Edit

Solved using threads. But not sure if it is safe ...

new Thread (()=>Runner.Run (h1));    
new Thread (()=>Runner.Run (h2));
+5
source share
2 answers

Note. This is only valid for Topshelf versions prior to 3.0. In 3.0, it was removed and replaced with other ways to host multiple services.

Unable to start multiple hosts. Running host block execution does a whole bunch of things. However, you can register multiple logical services on the same host.

https://github.com/Topshelf/Topshelf/wiki/Creating-a-service

return (int)HostFactory.Run(x => {
  x.Service<Service1>({ ... });
  x.Service<Service2>({ ... ]);
}); 

AppDomain. . AppDomains, . http://topshelf-project.com/documentation/shelving/ , , , .

+1

Topshelf docs:

ONE! 3.x Topshelf . , . . , , nuget.

+8
source

All Articles