Flush() public method

Clears all buffers for this stream and causes any buffered data to be written to the underlying device.
Clears all 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
Ejemplo n.º 1
0
        async Task <int> IterateAsync(bool doAsync)
        {
            if (stream == null)
            {
                throw new InvalidOperationException();
            }

            if (queue.Count == 0)
            {
                return(0);
            }

            int count             = (Capabilities & Pop3Capabilities.Pipelining) != 0 ? queue.Count : 1;
            var cancellationToken = queue[0].CancellationToken;
            var active            = new List <Pop3Command> ();

            if (cancellationToken.IsCancellationRequested)
            {
                queue.RemoveAll(x => x.CancellationToken.IsCancellationRequested);
                cancellationToken.ThrowIfCancellationRequested();
            }

            for (int i = 0; i < count; i++)
            {
                var pc = queue[0];

                if (i > 0 && !pc.CancellationToken.Equals(cancellationToken))
                {
                    break;
                }

                queue.RemoveAt(0);

                pc.Status = Pop3CommandStatus.Active;
                active.Add(pc);

                await SendCommandAsync(pc, doAsync, cancellationToken).ConfigureAwait(false);
            }

            if (doAsync)
            {
                await stream.FlushAsync(cancellationToken).ConfigureAwait(false);
            }
            else
            {
                stream.Flush(cancellationToken);
            }

            for (int i = 0; i < active.Count; i++)
            {
                await ReadResponseAsync(active[i], doAsync).ConfigureAwait(false);
            }

            return(active[active.Count - 1].Id);
        }
Ejemplo n.º 2
0
        public int Iterate()
        {
            if (stream == null)
            {
                throw new InvalidOperationException();
            }

            if (queue.Count == 0)
            {
                return(0);
            }

            int count             = (Capabilities & Pop3Capabilities.Pipelining) != 0 ? queue.Count : 1;
            var cancellationToken = queue[0].CancellationToken;
            var active            = new List <Pop3Command> ();

            if (cancellationToken.IsCancellationRequested)
            {
                queue.RemoveAll(x => x.CancellationToken.IsCancellationRequested);
                cancellationToken.ThrowIfCancellationRequested();
            }

            for (int i = 0; i < count; i++)
            {
                var pc = queue[0];

                if (i > 0 && !pc.CancellationToken.Equals(cancellationToken))
                {
                    break;
                }

                queue.RemoveAt(0);

                pc.Status = Pop3CommandStatus.Active;
                active.Add(pc);

                SendCommand(pc);
            }

            stream.Flush(cancellationToken);

            for (int i = 0; i < active.Count; i++)
            {
                ReadResponse(active[i]);
            }

            return(active[active.Count - 1].Id);
        }