System.IO.TextReader.ReadLineAsync C# (CSharp) Method

ReadLineAsync() public method

public ReadLineAsync ( ) : Task
return Task
        public virtual Task<string> ReadLineAsync()
        {
            return Task<String>.Factory.StartNew(state =>
            {
                return ((TextReader)state).ReadLine();
            },
            this, CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default);
        }

Usage Example

Example #1
0
        public static async Task<PemData> TryDecodeAsync(TextReader input)
        {
            // Read the header
            var header = GetBarrierName(await input.ReadLineAsync());
            if (header == null)
            {
                return null;
            }

            // Read the data
            List<string> dataLines = new List<string>();
            string line;
            while (!(line = await input.ReadLineAsync()).StartsWith("-"))
            {
                dataLines.Add(line);
            }
            byte[] data;
            try
            {
                data = Convert.FromBase64String(String.Concat(dataLines));
            }
            catch
            {
                return null; // Invalid Base64 String!
            }

            // Read the footer
            var footer = GetBarrierName(line);
            return new PemData(header, data, footer);
        }
All Usage Examples Of System.IO.TextReader::ReadLineAsync