in generators/CoreCLRStatelessService/templates/service/class/Program.cs [20:47]
public static void Main(string[] args)
{
try
{
//Creating a new event listener to redirect the traces to a file
ServiceEventListener listener = new ServiceEventListener();
listener.EnableEvents(ServiceEventSource.Current, EventLevel.LogAlways, EventKeywords.All);
// The ServiceManifest.XML file defines one or more service type names.
// Registering a service maps a service type name to a .NET type.
// When Service Fabric creates an instance of this service type,
// an instance of the class is created in this host process.
ServiceEventSource.Current.Message("Registering Service : {0}", "<%= serviceName %>");
ServiceRuntime.RegisterServiceAsync("<%= serviceTypeName %>",
context => new <%= serviceName %> (context)).GetAwaiter().GetResult();
ServiceEventSource.Current.Message("Registered Service : {0}", "<%= serviceName %>");
// Prevents this host process from terminating so services keep running.
Thread.Sleep(Timeout.Infinite);
}
catch (Exception ex)
{
ServiceEventSource.Current.ServiceHostInitializationFailed(ex);
throw ex;
}
}