public static void Create(string host, Dictionary<string, string> requestParams, string method, DownloadListener listener) { SimpleConnector connector = new SimpleConnector(); connector.SetServerName(host); connector.SetParams(requestParams); connector.OnRequestComplete += listener; if(method==SimpleConnector.METHOD_GET) { connector.SendGet(); } else { connector.SendPost(); } }
public void StartDownload(string aUrl, Action<string, DateTime> aCompleteCallback, Action aFailedCallback) { if (!iDownloads.ContainsKey(aUrl)) { FileStream fileStream; string fileName; iDownloadDirectory.CreateFile(out fileStream, out fileName); var downloadListener = new DownloadListener(this, aUrl, fileName, aCompleteCallback, aFailedCallback); iDownloads[aUrl] = downloadListener; downloadListener.Download = iUrlFetcher.Fetch(aUrl, fileStream, downloadListener); lock (iPublicDownloadInfo) { iPublicDownloadInfo[aUrl] = DownloadProgress.CreateJustStarted(aUrl); } InvokeDownloadChanged(EventArgs.Empty); } }
public static void Post(string host, Dictionary<string, string> requestParams, DownloadListener listener) { Create(host, requestParams, SimpleConnector.METHOD_POST, listener); }
public static void Post(string host, Dictionary <string, string> requestParams, DownloadListener listener) { Create(host, requestParams, SimpleConnector.METHOD_POST, listener); }
public static void Create(string host, Dictionary <string, string> requestParams, string method, DownloadListener listener) { SimpleConnector connector = new SimpleConnector(); connector.SetServerName(host); connector.SetParams(requestParams); connector.OnRequestComplete += listener; if (method == SimpleConnector.METHOD_GET) { connector.SendGet(); } else { connector.SendPost(); } }
public DownloadManager(IList <string> ugoiraLinks, ConnectionListener connectionListener = null, DownloadListener downloadListener = null, int threadCount = 4) { this.connectionListener = connectionListener; this.downloadListener = downloadListener; this.ugoiraLinks.AddRange(ugoiraLinks); threadCount = Math.Min(ugoiraLinks.Count, Math.Min(maxThreadCount, threadCount)); threads = new Thread[this.threadCount = threadCount]; for (int i = 0; i < threadCount; i++) { threads[i] = new Thread(new ThreadStart(run)) { IsBackground = true }; threads[i].SetApartmentState(ApartmentState.STA); } }