xvdiff
xvdiff

Reputation: 2229

Why has the OnStart() method from ServiceBase an arguments parameter?

Take the following example:

public static class Program {

    public static void Main(string[] args) {
        ServiceBase.Run(new DummyService());
    }

}

public class DummyService : ServiceBase {

    protected override void OnStart(string[] args) {

    }

}

The virtual method to override in ServiceBase passes a array of string arguments to the method body, however, when a application starts, it needs a main method which CAN already receive the startup arguments. So, what's the point of forcing the parameter to the OnStart() method signature?

Upvotes: 1

Views: 1131

Answers (1)

usr
usr

Reputation: 171206

A single process can host multiple services. You can pass arguments to a service when you start it. These arguments can be different for each service and in fact for each start of a service.

MSDN says

OnStart can take arguments as a way to pass data, but this usage is rare.

Upvotes: 3

Related Questions