Using VS2022, C# 10, RO 10.0.0.1533, .Net 6, WPF, code first
Since there are apparently no examples or documentation of using RO with Microsoft.Extensions.Hosting (and if there are, please point me to it), can someone suggest how I’m supposed to shutdown an RO server when using WPF?
I’m constructing/starting the server like this (along with various other things I’ve tried):
hostBuilder = ConstructHost();
host = hostBuilder.Build();
host.StartAsync();
and then I start WPF/my window, and all appears well at that point. The server starts, I can communicate with it, the window works, etc.
My problem comes when shutting down the server. When doing so, the Debug console shows me this:
Microsoft.Hosting.Lifetime: Information: Waiting for the host to be disposed. Ensure all ‘IHost’ instances are wrapped in ‘using’ blocks.
I tried using await host.StopAsync() but that never returns, so obviously that’s not the right way.
I have tried a number of things, and some serious Googling about how to deal with this, nothing worked and the examples on the internet don’t seem to match at all. The examples I’ve found are showing RO should be implementing IHostedService somewhere and I could just create a StopAsync and I should be fine. The problem is that I don’t seem to have a way/location to do that, services from ConfigureServices doesn’t seem to have AddHostedService
At this point, given no example or documentation, I’m not sure if I’m starting it wrong, trying to stop it wrong or just have a missing piece somewhere.