private void ThreadBody()
        {
            while (!Disposed)
            {
                byte[] package;

                while (this.outgoingPackageQueue.TryDequeue(out package))
                {
                    BytePackageUtil.WritePackage(_resourceFactory(), _cryptoProvider.Encrypt(package));
                }

                this.flushEvent.WaitOne(5000);
            }
        }
 private void Write(byte[] package)
 {
     BytePackageUtil.WritePackage(_streamFactory(), _cryptoProvider.Encrypt(package));
 }