21

I've a need to use topshelf in the project I'm in and have a simple question I hope. Everything works just fine when I'm using HostFactory.Run, but I thought that it seemed more reasonable to use HostFactory.New by just reading the name on the function and that is used here: http://docs.topshelf-project.com/en/latest/configuration/config_api.html.

However in the more simple example, http://docs.topshelf-project.com/en/latest/configuration/quickstart.html, the HostFactory.Run is used insted of HostFactory.New. So what is the difference?

Tomas Jansson
  • 20,796
  • 9
  • 68
  • 121

2 Answers2

19

Run pretty much just contains:

return New(configureCallback).Run();

So Run is just convenience method to create and immediately run the instance instead of just creating the instance as New does.

DavGarcia
  • 17,702
  • 14
  • 52
  • 94
16

HostFactory.Run will eat all exception, so it will silent exit, and you never know what caused it.

HostFactory.New

will throw the exception.

Getz
  • 3,807
  • 6
  • 33
  • 52
LoveJenny
  • 161
  • 1
  • 2
  • 2
    Kind of necro, but this needs an update. Just ran into this problem where "run" would execute without throwing anything but the process never actually ran. True to SO, the useful answers get downvoted. – Captain Prinny Feb 22 '17 at 16:50