Async Main samples (#2004)

This commit is contained in:
Ben Adams 2017-08-18 22:46:19 +01:00 committed by Stephen Halter
parent 7f23ff08ce
commit 59b77bb357
2 changed files with 4 additions and 5 deletions

View File

@ -15,7 +15,6 @@ namespace LargeResponseApp
private const int _chunkSize = 4096; private const int _chunkSize = 4096;
private const int _defaultNumChunks = 16; private const int _defaultNumChunks = 16;
private static byte[] _chunk = Encoding.UTF8.GetBytes(new string('a', _chunkSize)); private static byte[] _chunk = Encoding.UTF8.GetBytes(new string('a', _chunkSize));
private static Task _emptyTask = Task.FromResult<object>(null);
public void Configure(IApplicationBuilder app) public void Configure(IApplicationBuilder app)
{ {
@ -38,7 +37,7 @@ namespace LargeResponseApp
}); });
} }
public static void Main(string[] args) public static Task Main(string[] args)
{ {
var host = new WebHostBuilder() var host = new WebHostBuilder()
.UseKestrel(options => .UseKestrel(options =>
@ -49,7 +48,7 @@ namespace LargeResponseApp
.UseStartup<Startup>() .UseStartup<Startup>()
.Build(); .Build();
host.Run(); return host.RunAsync();
} }
} }
} }

View File

@ -35,7 +35,7 @@ namespace SampleApp
}); });
} }
public static void Main(string[] args) public static Task Main(string[] args)
{ {
TaskScheduler.UnobservedTaskException += (sender, e) => TaskScheduler.UnobservedTaskException += (sender, e) =>
{ {
@ -89,7 +89,7 @@ namespace SampleApp
.UseStartup<Startup>() .UseStartup<Startup>()
.Build(); .Build();
host.Run(); return host.RunAsync();
} }
} }
} }