コード例 #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();
     }
 }
コード例 #2
0
ファイル: Downloader.cs プロジェクト: weeble/ohos
 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);
     }
 }
コード例 #3
0
 public static void Post(string host, Dictionary<string, string> requestParams, DownloadListener listener)
 {
     Create(host, requestParams, SimpleConnector.METHOD_POST, listener);
 }
コード例 #4
0
 public static void Post(string host, Dictionary <string, string> requestParams, DownloadListener listener)
 {
     Create(host, requestParams, SimpleConnector.METHOD_POST, listener);
 }
コード例 #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();
            }
        }
コード例 #6
0
        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);
            }
        }