MailKit.Net.Imap.ImapStream.Flush C# (CSharp) Method

Flush() public method

Clears all output buffers for this stream and causes any buffered data to be written to the underlying device.
Clears all output buffers for this stream and causes any buffered data to be written to the underlying device.
/// The stream has been disposed. /// /// The stream does not support writing. /// /// An I/O error occurred. ///
public Flush ( ) : void
return void
		public override void Flush ()
		{
			Flush (CancellationToken.None);
		}

Same methods

ImapStream::Flush ( CancellationToken cancellationToken ) : void

Usage Example

Example #1
0
        /// <summary>
        /// Write the literal to the specified stream.
        /// </summary>
        /// <remarks>
        /// Writes the literal to the specified stream.
        /// </remarks>
        /// <param name="stream">The stream.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        public void WriteTo(ImapStream stream, CancellationToken cancellationToken)
        {
            if (Type == ImapLiteralType.String)
            {
                var bytes = (byte[])Literal;
                stream.Write(bytes, 0, bytes.Length, cancellationToken);
                stream.Flush(cancellationToken);
                return;
            }

            if (Type == ImapLiteralType.MimeMessage)
            {
                var message = (MimeMessage)Literal;

                message.WriteTo(format, stream, cancellationToken);
                stream.Flush(cancellationToken);
                return;
            }

            var literal = (Stream)Literal;
            var buf     = new byte[4096];
            int nread;

            while ((nread = literal.Read(buf, 0, buf.Length)) > 0)
            {
                stream.Write(buf, 0, nread, cancellationToken);
            }

            stream.Flush(cancellationToken);
        }
All Usage Examples Of MailKit.Net.Imap.ImapStream::Flush