what is the difference between HostFactory.Run and HostFactory.New
Asked Answered
T

2

22

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?

Tret answered 22/3, 2013 at 10:24 Comment(2)
See the source - github.com/phatboyg/Topshelf/blob/master/src/Topshelf/…Vedette
@stuartd, thank you. So basically the new creates a host but run creates and runs it.Tret
U
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.

Unschooled answered 24/4, 2013 at 21:19 Comment(1)
There is more to it. See LoveJenny's answer.Acrospire
T
17

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

HostFactory.New

will throw the exception.

Tunnel answered 7/8, 2014 at 8:35 Comment(1)
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.Mccary

© 2022 - 2024 — McMap. All rights reserved.