Search code examples
c#console-applicationazure-service-fabricguest-executable

Keeping a console application alive in Service Fabric


Are there any established patterns for keeping console applications alive when hosted as guest executables in Service Fabric?

Adding a Thread.Sleep(Timeout.Infinite) after I've subscribed to Service Bus or similar feels like a bit of a hack to me. Other approaches I've seen use Console.ReadKey(), but, again, this feels like a hack.


Solution

  • Thread.Sleep(Timeout.Infinite) appears to be what's recommended by Microsoft according to their Azure Service Fabric samples in GitHub:

    https://github.com/Azure-Samples/service-fabric-dotnet-getting-started/blob/master/src/GettingStartedApplication/ActorBackendService/Program.cs