/// <summary> /// Get the next response within the given timeout. /// </summary> /// <param name="response">The first response in the queue, if any.</param> /// <param name="millisTimeout">The maximum number of milliseconds to wait for a response.</param> /// <returns>True if there was a response to get, false otherwise.</returns> public bool TryGetResponse(string id, out LspResponse response, int millisTimeout) { if (_responses.TryRemove(id, out response)) { return(true); } if (_responseReceivedChannel.TryTake(out bool _, millisTimeout)) { return(_responses.TryRemove(id, out response)); } response = null; return(false); }
/// <summary> /// Get the next response if there is one, otherwise instantly return false. /// </summary> /// <param name="response">The first response in the response queue if any, otherwise null.</param> /// <returns>True if there was a response to get, false otherwise.</returns> public bool TryGetResponse(string id, out LspResponse response) { _responseReceivedChannel.TryTake(out bool _, millisecondsTimeout: 0); return(_responses.TryRemove(id, out response)); }
/// <summary> /// Get the next response from the server, if one is available within the given time. /// </summary> /// <param name="response">The next response from the server.</param> /// <param name="millisTimeout">How long to wait for a response.</param> /// <returns>True if there is a next response, false if it timed out.</returns> public bool TryGetResponse(string id, out LspResponse response, int millisTimeout) { return(_listener.TryGetResponse(id, out response, millisTimeout)); }