xxxxxxxxxx
private WebApplication? _app;
public MainWindow()
{
InitializeComponent();
Task.Run(() => StartServer());
}
private void StartServer()
{
var builder = WebApplication.CreateBuilder();
// Despite adding a "launchSettings.json" file to the project, I couldn't find a way
// for the builder to pick it up, so had to configure the URLs here:
builder.WebHost.UseUrls("http://*:5219", "https://*:7219");
builder.Services.AddGrpc();
_app = builder.Build();
_app.MapGrpcService<TestService>();
_app.Run();
}
private void MainWindow_OnClosing(object? sender, CancelEventArgs e)
{
_app?.StopAsync();
}
xxxxxxxxxx
private WebApplication? _app;
public MainWindow()
{
InitializeComponent();
Task.Run(() => StartServer());
}
private void StartServer()
{
var builder = WebApplication.CreateBuilder();
// Despite adding a "launchSettings.json" file to the project, I couldn't find a way
// for the builder to pick it up, so had to configure the URLs here:
builder.WebHost.UseUrls("http://*:5219", "https://*:7219");
builder.Services.AddGrpc();
_app = builder.Build();
_app.MapGrpcService<TestService>();
_app.Run();
}
private void MainWindow_OnClosing(object? sender, CancelEventArgs e)
{
_app?.StopAsync();
}