From 3bf3018f64678d83f534ebf9812a3307a9f22ff2 Mon Sep 17 00:00:00 2001 From: Brad Jones Date: Wed, 22 Jul 2015 18:32:58 +1000 Subject: [PATCH] Fixes OmniSharp/omnisharp-roslyn#272 On my system I found that 4 seconds was not logn enough for DHT to start. Time for a new computer perhaps... Anyway I have bumped the timeout to 10 seconds (FYI: my system on average took 6 seconds to start DHT). I have also added in a check to see if the timeout has indeed been reached. --- src/OmniSharp/Dnx/DesignTimeHostManager.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/OmniSharp/Dnx/DesignTimeHostManager.cs b/src/OmniSharp/Dnx/DesignTimeHostManager.cs index d982ccc047..a141a83de0 100644 --- a/src/OmniSharp/Dnx/DesignTimeHostManager.cs +++ b/src/OmniSharp/Dnx/DesignTimeHostManager.cs @@ -63,7 +63,7 @@ public void Start(string hostId, Action onConnected) using (var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)) { var t1 = DateTime.UtcNow; - var dthTimeout = TimeSpan.FromSeconds(4); + var dthTimeout = TimeSpan.FromSeconds(10); while (!socket.Connected && DateTime.UtcNow - t1 < dthTimeout) { Thread.Sleep(500); @@ -76,6 +76,13 @@ public void Start(string hostId, Action onConnected) // this happens when the DTH isn't listening yet } } + + if (!socket.Connected) + { + // reached timeout + _logger.LogError("Failed to launch DesignTimeHost in a timely fashion."); + return; + } } if (_designTimeHostProcess.HasExited) @@ -98,7 +105,7 @@ public void Start(string hostId, Action onConnected) onConnected(port); } } - + public void Stop() { lock (_processLock)