public TcpSink(ITcpClient clientImpl, Uri uri) { _formatter = new JsonFormatter(); if (uri.Scheme.ToLower() == "tls") { _client = clientImpl.Create(uri.Host, uri.Port, true); } else { _client = clientImpl.Create(uri.Host, uri.Port, false); } _cancellationTokenSource = new CancellationTokenSource(); _sendqueue = new ConcurrentQueue <Tuple <byte[], int, int> >(); _sendThread = Task.Factory.StartNew((arg) => SendLoop(), _cancellationTokenSource.Token, TaskCreationOptions.LongRunning); _syncQueue = new object(); }