public static List <string> DownloadStrings(List <string> urls, string cookie = "", Action complete = null) { var interrupt = new ManualResetEvent(false); var result = new string[urls.Count]; var count = urls.Count; int iter = 0; foreach (var url in urls) { var itertmp = iter; var task = NetTask.MakeDefault(url); task.DownloadString = true; task.CompleteCallbackString = (str) => { result[itertmp] = str; if (Interlocked.Decrement(ref count) == 0) { interrupt.Set(); } complete?.Invoke(); }; task.ErrorCallback = (code) => { if (Interlocked.Decrement(ref count) == 0) { interrupt.Set(); } }; task.Cookie = cookie; AppProvider.Scheduler.Add(task); iter++; } interrupt.WaitOne(); return(result.ToList()); }
public abstract void RunOnPass(ref NetTask content);
public static void RunOnField(ref NetTask content) { foreach (var pass in Passes) pass.RunOnPass(ref content); }
public static string DownloadString(NetTask task) { return(DownloadStringAsync(task).Result); }
public static string DownloadString(string url) { return(DownloadStringAsync(NetTask.MakeDefault(url)).Result); }