JsonRpcMessageHandler.cs 975 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
// Copyright (c) Microsoft.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information.

using System.IO;
using StreamJsonRpc;

namespace Microsoft.VisualStudio.LanguageServices.Remote
{
    // This is a workaround for a limitation in vs-threading.
    // https://github.com/dotnet/roslyn/issues/19042
    internal class JsonRpcMessageHandler : HeaderDelimitedMessageHandler
    {
        public JsonRpcMessageHandler(Stream sendingStream, Stream receivingStream)
            : base(sendingStream, receivingStream)
        {
        }

        protected override void Dispose(bool disposing)
        {
            // Do not call base.Dispose. We do not want the AsyncSemaphore instances to be disposed due to a race
            // condition.

            if (disposing)
            {
                ReceivingStream?.Dispose();
                SendingStream?.Dispose();
            }
        }
    }
}