//private static readonly Timer _timer = new Timer(_ => //{ // Console.WriteLine("GC.Collect"); // GC.Collect(); // GC.WaitForPendingFinalizers(); // GC.Collect(); //}, null, 0, 3000); static async Task _Main() { Trace.Listeners.Add(new TextWriterTraceListener(Console.Out)); //GuiLikeSyncContext.Install(); Console.WriteLine(SynchronizationContext.Current); var serviceProvider = ConfigureServices(); // build and run service host var host = new ServiceHostBuilder(serviceProvider) .UseNamedPipes(new NamedPipeSettings("test") { RequestTimeout = TimeSpan.FromSeconds(2), AccessControl = security => security.AllowCurrentUser(), }) .AddEndpoint <IComputingService, IComputingCallback>() .AddEndpoint <ISystemService>() .ValidateAndBuild(); await await Task.WhenAny(host.RunAsync(), Task.Run(() => { Console.WriteLine(typeof(int).Assembly); Console.ReadLine(); host.Dispose(); })); Console.WriteLine("Server stopped."); }
public static async Task MainAsync(string[] args) { var host = new ServiceHostBuilder(new OpinionatedFooBootstrap()) .UseConsoleHost() .UseWebHost() .Build(); await host.RunAsync(); }