Ejemplo n.º 1
0
 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();
     }
 }
Ejemplo n.º 2
0
 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);
     }
 }
Ejemplo n.º 3
0
 public static void Post(string host, Dictionary<string, string> requestParams, DownloadListener listener)
 {
     Create(host, requestParams, SimpleConnector.METHOD_POST, listener);
 }
Ejemplo n.º 4
0
 public static void Post(string host, Dictionary <string, string> requestParams, DownloadListener listener)
 {
     Create(host, requestParams, SimpleConnector.METHOD_POST, listener);
 }
Ejemplo n.º 5
0
        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);
            }
        }