public void ThreadPoolCallBack(object threadContext) { string uri = (string)threadContext; IRequestHandler requestHandler = new HttpWebRequestHandler(); string response = requestHandler.GetRestItems(uri); string value = JObject.Parse(response)[Program.Property].ToString(); Console.WriteLine("Current thread: {0}, {1}", Thread.CurrentThread.ManagedThreadId, value); _doneEvent.Set(); }
public void DoWork() { IRequestHandler requestHandler = new HttpWebRequestHandler(); string response = GetItems(requestHandler, _uri); if (string.IsNullOrEmpty(response) || JObject.Parse(response)[Program.Property] == null) { throw new ApplicationException(); } string value = JObject.Parse(response)[Program.Property].ToString(); Console.WriteLine("Current thread: {0}, {1}", Thread.CurrentThread.ManagedThreadId, value); }
public string GetRestItem(string uri) { IRequestHandler requestHandler = new HttpWebRequestHandler(); string response = requestHandler.GetRestItems(uri); if (!string.IsNullOrEmpty(response) && JObject.Parse(response)[Program.Property] != null) { return(JObject.Parse(response)[Program.Property].ToString().Trim()); } else { throw new ApplicationException(); } }
public void ThreadPoolCallBack(object threadContext) { string url = (string)threadContext; IRequestHandler httpWebRequestHandler = new HttpWebRequestHandler(); string response = httpWebRequestHandler.GetRestItems(url); string value = JObject.Parse(response)[_property].ToString(); Console.WriteLine("Current thread: {0}, {1}", Thread.CurrentThread.ManagedThreadId, value); if (!string.IsNullOrEmpty(value) && !string.Equals(value, "[]")) { _values.Add(value); } _doneEvent.Set(); }
public List <string> GetRestItemsFilm() { DisplayProcess(); char[] chars = new char[] { '[', '\r', '\n', ']', ' ', '\"' }; string[] s = new string[] { "\",\r\n \"" }; string url = "https://swapi.dev/api/films/?search=" + Program.Title; IRequestHandler requestHandler = new HttpWebRequestHandler(); string response = requestHandler.GetRestItems(url); JToken token = JObject.Parse(response).SelectToken("results"); if (token.HasValues && token[0][Program.Item] != null) { string filmItems = token[0][Program.Item].ToString().TrimStart(chars).TrimEnd(chars); return(filmItems.Split(s, StringSplitOptions.None).ToList()); } else { throw new ApplicationException(); } }