Esempio n. 1
0
        async Tasks.Task <bool> FlushBuffer()
        {
            byte[] array;
            int    count;

            lock (this.outBufferLock)
            {
                array          = (byte[])this.outBuffer;
                count          = this.outBuffer.Count;
                this.outBuffer = new Collection.Array.List <byte>(this.outBuffer.Capacity);
            }
            bool result;

            if (result = count > 0)
            {
                await this.stream.WriteAsync(array, 0, count);
            }
            return(result);
        }
Esempio n. 2
0
		public bool Flush()
		{
			byte[] array;
			int count;
			lock (this.outBufferLock)
			{
				array = (byte[])this.outBuffer;
				count = this.outBuffer.Count;
				this.outBuffer = new Collection.Array.List<byte>(this.outBuffer.Capacity);
			}
			bool result = this.stream.NotNull();
			if (result && count > 0)
			{
				this.stream.Write(array, 0, count);
				this.stream.Flush();
			}
			return result;
		}