public void Success(object sender, Microsoft.ServiceBus.Channels.IConnection connection) { lock (this.ThisLock) { if (!this.complete) { this.complete = true; } else { connection.Close(TimeSpan.FromSeconds(1)); return; } } this.listener.Success(this, connection); }
private void SendInitiateMessage(Microsoft.ServiceBus.Channels.IConnection connection, TimeSpan timeout) { try { TimeoutHelper timeoutHelper = new TimeoutHelper(timeout); byte[] byteArray = this.connectionId.ToByteArray(); connection.Write(byteArray, 0, (int)byteArray.Length, true, timeoutHelper.RemainingTime()); byte[] numArray = new byte[1]; if (connection.Read(numArray, 0, 1, timeoutHelper.RemainingTime()) < 1 || numArray[0] != 1) { throw new CommunicationException(SRClient.InvalidReceivedContent); } } catch { connection.Close(TimeSpan.Zero); throw; } }