Reputation: 315
I am wondering if there is a way to terminate hosted as a console servicestack service on a web request?
I tried windows forms application with embedded browser but it feels much slower than google chrome. So my plan is to run a console application in a background and terminate it on user action in browser.
Upvotes: 0
Views: 37
Reputation: 143319
You can just call Environment.Exit(0);
to quit the .NET Application. To increase the perceived performance just hide the Window before you exit, e.g:
formMain.InvokeOnUiThreadIfRequired(() =>
{
formMain.Hide();
formMain.Close();
});
I highly recommend checking out the new React Desktop Apps template which automatically includes running ServiceStack embedded inside a Chromium browser in a Winforms App, an OSX Cocoa App as well as a cross-platform Win/Linux/OSX Console App.
The React Chat Apps Example App does exactly what you're after, i.e. closing the App from a Webservice request to quit the running application. Here's a YouTube demo of it in action that shows quiting multiple Window Application instances from a Web Service Request.
Upvotes: 1