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.
Thread.Sleep(Timeout.Infinite)
appears to be what's recommended by Microsoft according to their Azure Service Fabric samples in GitHub:
Console.ReadKey() is perfectly fine. You can Write a message before like
Console.WriteLine("Press any key to end...");
Console.ReadKey();
so the user knows how to end the application.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.