View TaskResultUtil.cs
class TaskResultUtil
private static ConcurrentDictionary<Type, ITaskResultGetter> _cachedGetters = new ConcurrentDictionary<Type, ITaskResultGetter>();
private interface ITaskResultGetter
object GetResult(Task task);
private class TaskResultGetter<T> : ITaskResultGetter
View Program.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
View Home.cshtml
@using StandaloneApp.Util
<h1>Hello, world!</h1>
Welcome to your new app.
<button @onclick(DoRequest)>Do request</button>
<div><strong>Response: </strong>@responseText</div>
@functions {
View somefile.cs
public class MyNetworkClient {
public event SomeDelegate OnException;
public async Task ConnectAsync(string address) {
await this.MakeTheActualConnection(address);
// It's async void! But is that bad?
// I know that an unhandled exception here is going to bring down the process, but where else do you want