private static void Write( WebRequestState completedState, string text) { lock (ConsoleSyncObject) { Console.SetCursorPosition( completedState.ConsoleColumn, completedState.ConsoleLine); Console.Write(text); completedState.ConsoleColumn += text.Length; } }
private static void Write( WebRequestState completedState, string text) { lock(ConsoleSyncObject) { Console.SetCursorPosition( completedState.ConsoleColumn, completedState.ConsoleLine); Console.Write(text); completedState.ConsoleColumn += text.Length; } }
DisplayPageSizeAsync(WebRequestState state) { string url = state.Url; WebRequest webRequest = WebRequest.Create(url); Write(state, url + " "); WebResponse webResponse = await Task<WebResponse>.Factory.FromAsync( webRequest.BeginGetResponse, webRequest.EndGetResponse, state); Stream stream = webResponse.GetResponseStream(); using(StreamReader reader = new StreamReader(stream)) { int length = reader.ReadToEnd().Length; Write(state, FormatBytes(length).ToString()); } }
DisplayPageSizeAsync(WebRequestState state) { string url = state.Url; WebRequest webRequest = WebRequest.Create(url); Write(state, url + " "); WebResponse webResponse = await Task <WebResponse> .Factory.FromAsync( webRequest.BeginGetResponse, webRequest.EndGetResponse, state); Stream stream = webResponse.GetResponseStream(); using (StreamReader reader = new StreamReader(stream)) { int length = reader.ReadToEnd().Length; Write(state, FormatBytes(length).ToString()); } }
private static void DisplayProgress( WebRequestState state) { lock (ConsoleSyncObject) { int left = state.ConsoleColumn; int top = state.ConsoleLine; if (left >= Console.BufferWidth - int.MaxValue.ToString().Length) { left = state.Url.Length; Console.SetCursorPosition(left, top); Console.Write("".PadRight( Console.BufferWidth - state.Url.Length)); state.ConsoleColumn = left; } Write(state, "."); } }
private static void DisplayProgress( WebRequestState state) { lock(ConsoleSyncObject) { int left = state.ConsoleColumn; int top = state.ConsoleLine; if(left >= Console.BufferWidth - int.MaxValue.ToString().Length) { left = state.Url.Length; Console.SetCursorPosition(left, top); Console.Write("".PadRight( Console.BufferWidth - state.Url.Length)); state.ConsoleColumn = left; } Write(state, "."); } }