Last active
April 10, 2017 17:15
-
-
Save pakrym/321de275fafbdfdedefe9441e4acd983 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.IO; | |
using System.Linq; | |
using System.Net.Http; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Hosting; | |
namespace WebApplication2 | |
{ | |
public class Program : IObserver<DiagnosticListener>, IObserver<KeyValuePair<string, object>> | |
{ | |
public static void Main(string[] args) | |
{ | |
new Program().MainImpl(args); | |
} | |
public void MainImpl(string[] args) | |
{ | |
DiagnosticListener.AllListeners.Subscribe(this); | |
var host = new WebHostBuilder() | |
.UseKestrel() | |
.UseContentRoot(Directory.GetCurrentDirectory()) | |
.UseIISIntegration() | |
.UseStartup<Startup>() | |
.UseApplicationInsights() | |
.Build(); | |
host.Start(); | |
new HttpClient().GetAsync("http://localhost:5000//") | |
.ContinueWith(task => | |
{ | |
Console.WriteLine("Request done"); | |
}) | |
.GetAwaiter().GetResult(); | |
Console.WriteLine("Before Dispose"); | |
host.Dispose(); | |
Console.WriteLine("After Dispose"); | |
Console.ReadLine(); | |
} | |
public void OnCompleted() | |
{ | |
} | |
public void OnError(Exception error) | |
{ | |
} | |
public void OnNext(KeyValuePair<string, object> value) | |
{ | |
Console.WriteLine(value.Key); | |
if (value.Key == "Microsoft.AspNetCore.Hosting.HttpRequestIn.Stop") | |
{ | |
Thread.Sleep(3000); | |
Console.WriteLine("After Microsoft.AspNetCore.Hosting.HttpRequestIn.Stop"); | |
} | |
} | |
public void OnNext(DiagnosticListener value) | |
{ | |
value.Subscribe(this); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment