当前位置: 首页>>代码示例>>C#>>正文


C# WebClient.DownloadStringAsync方法代码示例

本文整理汇总了C#中System.Net.WebClient.DownloadStringAsync方法的典型用法代码示例。如果您正苦于以下问题:C# WebClient.DownloadStringAsync方法的具体用法?C# WebClient.DownloadStringAsync怎么用?C# WebClient.DownloadStringAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Net.WebClient的用法示例。


在下文中一共展示了WebClient.DownloadStringAsync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Initialize

 //方法
 public void Initialize()
 {
     WebClient wc = new WebClient();
     wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);
     if (Credential.CREDENTIAL.GetUrlParameters() != null)
     {
         string s = string.Format("{0}.json" +"?"+ Credential.CREDENTIAL.GetUrlParameters(), MapServiceUrl);
         wc.DownloadStringAsync(new Uri(s, UriKind.Absolute), this);
     }
     else {
         wc.DownloadStringAsync(new Uri(string.Format("{0}.json", MapServiceUrl), UriKind.Absolute), this);
     }
 }
开发者ID:SuperMap,项目名称:iClient-for-Silverlight,代码行数:14,代码来源:SmMapService.cs

示例2: AddQuestion

 public void AddQuestion(string Question)
 {
     Uri xmlUri = new Uri(srvStr + "AddQuestion?q=" + Question);
     WebClient aqFeed = new WebClient();
     aqFeed.DownloadStringCompleted += new DownloadStringCompletedEventHandler(aqFeed_DownloadStringCompleted);
     aqFeed.DownloadStringAsync(xmlUri);
 }
开发者ID:astubbs,项目名称:datacom-2010-devcamp-projects,代码行数:7,代码来源:MainPage.xaml.cs

示例3: read_api

        public void read_api(string content_id)
        {
            WebClient myService = new WebClient();
            url = null;
            try
            {
                if (content_id != null)
                {
                    SetLoadingPanelVisibility(true);

                    url = "http://mstage.truelife.com/api_movietv/drama/music?method=getinfo&content_id=";


                    Debug.WriteLine(url + content_id);

                    myService.DownloadStringAsync(new Uri(url + content_id));
                    myService.DownloadStringCompleted += new DownloadStringCompletedEventHandler(GetTotal_Completed);
                }
                else
                {
                    throw new Exception("Content id is NULL !");
                }

            }
            catch (WebException ex)
            {
                MessageBox.Show(ex.Message);
            }

        }
开发者ID:KongMono,项目名称:HTV_WP,代码行数:30,代码来源:MusicPage.xaml.cs

示例4: LoadMovies

 //public void LoadMovies()
 //{
 //    Thread.Sleep(5000);
 //    var handler = OnLoadMovies;
 //    if (handler != null)
 //        handler(new LoadMoviesEventArgs {MultiplexId = _multiplexId});
 //}
 public void LoadMovies()
 {
     var client = new WebClient();
     client.DownloadStringCompleted += GetMoviesCompleted;
     var path = string.Format(Movie.MoviesUri, _multiplexId);
     client.DownloadStringAsync(new Uri(path, UriKind.Absolute));
 }
开发者ID:kap0ton,项目名称:Cinemapark_WP7,代码行数:14,代码来源:MovieService.cs

示例5: GetVEServiceKey

 private void GetVEServiceKey()
 {
     WebClient wc = new WebClient();
     wc.DownloadStringCompleted += this.WebClientDownloadStringCompleted;
     Uri keyURI = new Uri(URIHelper.CurrentApplicationURL, "VEKey.txt");
     wc.DownloadStringAsync(keyURI);
 }
开发者ID:netintellect,项目名称:PluralsightSpaJumpStartFinal,代码行数:7,代码来源:Example.xaml.cs

示例6: addUsrBtn_Click

 private void addUsrBtn_Click(object sender, RoutedEventArgs e)
 {
     this.loginStatus.Text = "Please wait while we try to log you in...";
     WebClient client = new WebClient();
     client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
     client.DownloadStringAsync(new Uri(string.Format(SyncContextInstance.LoginUriFormat, this.unameTxt.Text)));
 }
开发者ID:rafek,项目名称:SyncFx,代码行数:7,代码来源:BootstrapView.xaml.cs

示例7: appbar_button1_Click

 private void appbar_button1_Click(object sender, EventArgs e)
 {
     listdata.Visibility = Visibility.Collapsed;
     listdata2.Visibility = Visibility.Collapsed;
     listdata3.Visibility = Visibility.Collapsed;
     loadtext.Visibility = Visibility.Visible;
     pgbar.Visibility = Visibility.Visible;
     var item = (PivotItem)title.SelectedItem;
     string header = (string)item.Header;
     if (header == "recent")
     {
         string url = String.Format("https://graph.facebook.com/me/home?access_token={0}", (string)settings["facebook_token"]);
         WebClient wc = new WebClient();
         wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_openHandler);
         wc.DownloadStringAsync(new Uri(url), UriKind.Absolute);
     }
     else if (header == "inbox")
     {
         string url = String.Format("https://api.facebook.com/method/message.getThreadsInFolder?access_token={0}&format=json", (string)settings["facebook_token"]);
         WebClient wc = new WebClient();
         wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_openHandler2);
         wc.DownloadStringAsync(new Uri(url), UriKind.Absolute);
     }
     else if (header == "my")
     {
         string url = String.Format("https://graph.facebook.com/me/feed?access_token={0}", (string)settings["facebook_token"]);
         WebClient wc = new WebClient();
         wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_openHandler3);
         wc.DownloadStringAsync(new Uri(url), UriKind.Absolute);
     }
 }
开发者ID:vapps,项目名称:HDStream,代码行数:31,代码来源:FacebookView.xaml.cs

示例8: GetProjects

 public void GetProjects(string rootUrl, string userName, string password, GetProjectsCompleteDelegate complete, Action<Exception> onError)
 {
     WebClient webClient = new WebClient
     {
         Credentials = new NetworkCredential(userName, password)
     };
     rootUrl = GetRootUrl(rootUrl);
     var projectUrl = new Uri(rootUrl + "/json/builders");
     webClient.DownloadStringCompleted += (s, e) =>
     {
         try
         {
             JavaScriptSerializer serializer = new JavaScriptSerializer();
             Dictionary<string, BuildBotBuildersJSONQuery> builders = serializer.Deserialize<Dictionary<string, BuildBotBuildersJSONQuery>>(e.Result);
             var builds = new List<BuildBotBuildDefinition>();
             foreach (KeyValuePair<string, BuildBotBuildersJSONQuery> kvp in builders)
             {
                 var buildurl = new Uri(rootUrl + "/json/builders/" + kvp.Key );
                 builds.Add( new BuildBotBuildDefinition(buildurl.ToString(), kvp.Key ) );
             }
             complete(builds.ToArray());
         }
         catch (Exception ex)
         {
             _log.Error("Error connecting to server", ex);
             onError(ex);
         }
     };
     webClient.DownloadStringAsync(projectUrl);
 }
开发者ID:dirkrombauts,项目名称:SirenOfShame,代码行数:30,代码来源:BuildBotService.cs

示例9: RequestData

 /// <summary>
 /// Method to call webservice
 /// </summary>
 public void RequestData()
 {
     string url = RxConstants.ConditionSearchUrl + App.ConditionSearchName + RxConstants.ApiKey;
     WebClient webClient = new WebClient();
     webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadStringCompleted);
     webClient.DownloadStringAsync(new Uri(url));
 }
开发者ID:EdytaSzkiladz,项目名称:MyLocalPharmacy,代码行数:10,代码来源:ConditionSearchModel.cs

示例10: LookupProduct

        public void LookupProduct(string upc, Action<ScanditProduct> onComplete)
        {
            var wc = new WebClient();
            wc.DownloadStringCompleted += (s, e) =>
                {
                    ScanditProduct product = null;

                    try
                    {
                        product = JsonConvert.DeserializeObject<ScanditProduct>(e.Result);
                    }
                    catch (Exception)
                    {
                    }

                    if (onComplete != null)
                        onComplete(product);
                };

            try
            {
                wc.DownloadStringAsync(
                    new Uri(string.Format("https://api.scandit.com/v1/products/{0}?key={1}", upc, Config.SCANDIT_API_KEY)));
            }
            catch
            {
                if (onComplete != null)
                    onComplete(null);
            }
        }
开发者ID:Redth,项目名称:WshLst,代码行数:30,代码来源:BarcodeApplicationObject.cs

示例11: Checker

 public Checker(string name, string twitch, string youtube, string facebook)
 {
     this.name = name;
     this.twitch = twitch;
     this.youtube = youtube;
     this.facebook = facebook;
     defaultImage = "Image/unknown.png";
     try
     {
         using (WebClient webClient = new WebClient())
         {
             webClient.DownloadStringCompleted += (a, b) =>
             {
                 if (!b.Cancelled)
                 {
                     string xmlString = b.Result;
                     XmlReader reader = XmlReader.Create(new StringReader(xmlString));
                     reader.ReadToFollowing("media:thumbnail");
                     defaultImage = reader["url"];
                 };
             };
             webClient.DownloadStringAsync(new Uri("http://gdata.youtube.com/feeds/api/users/" + youtube));
         }
     }
     catch
     {
         defaultImage = "Image/unknown.png";
     }
     Check(0, "", true);
 }
开发者ID:WebFreak001,项目名称:thelocknlol-checker-executable,代码行数:30,代码来源:Checker.cs

示例12: Download

        /// <summary>
        /// Download text from a URL.
        /// A promise is returned that is resolved when the download has completed.
        /// The promise is rejected if an error occurs during download.
        /// </summary>
        static IPromise<string> Download(string url)
        {
            Console.WriteLine("Downloading " + url + " ...");

            var promise = new Promise<string>();
            using (var client = new WebClient())
            {
                client.DownloadStringCompleted +=
                    (s, ev) =>
                    {
                        if (ev.Error != null)
                        {
                            Console.WriteLine("An error occurred... rejecting the promise.");

                            // Error during download, reject the promise.
                            promise.Reject(ev.Error);
                        }
                        else
                        {
                            Console.WriteLine("... Download completed.");

                            // Downloaded completed successfully, resolve the promise.
                            promise.Resolve(ev.Result);
                        }
                    };

                client.DownloadStringAsync(new Uri(url), null);
            }
            return promise;
        }
开发者ID:avenema,项目名称:C-Sharp-Promise,代码行数:35,代码来源:Program.cs

示例13: checkForUpdates

        private async void checkForUpdates()
        {
            using (WebClient wc = new WebClient())
            {
                wc.DownloadStringCompleted += (sender, e) =>
                {
                    if (e.Error != null)
                    {
                        processTooltip.Text = "Update Checker Timed Out :(";
                    }
                    else
                    {
                        string versionString = e.Result;
                        string[] versions = versionString.Split('.');
                        int[] intver = new int[versions.Length];

                        for (int i = 0; i < versions.Length; i++)
                        {
                            string ver = versions[i];
                            int veri;
                            if (Int32.TryParse(ver, out veri))
                            {
                                intver[i] = veri;
                            }
                            else
                            {
                                intver[i] = 0;
                            }
                        }
                        newVersionAvailableToolStripMenuItem.Visible = compareVersionAndCheckIfNewer(intver);
                    }
                };
                wc.DownloadStringAsync(new Uri("http://android.itachi1706.com/apps/updates/MoodleHelper"));
            }
        }
开发者ID:itachi1706,项目名称:MoodleHelper,代码行数:35,代码来源:FlywayForm.cs

示例14: LoadIsolatedStorage

        private void LoadIsolatedStorage()
        {
            if (isoData.Contains("lstSessions"))
            {
                lstSessions = (List<Models.Sessions>)isoData["lstSessions"];
                Dispatcher.BeginInvoke(DisplaySessions);
            }
            else
            {
                lstSessions = new List<Models.Sessions>();
                isoData.Add("lstSessions", lstSessions);
            }

            if (isoData.Contains("lastPulledSessions"))
            {
                lastPulled = (DateTime)isoData["lastPulledSessions"];
            }

            isoData.Save();

            if (NetworkInterface.GetIsNetworkAvailable() && lastPulled.AddDays(1) <= DateTime.Now)
            {
                var wc = new WebClient();
                wc.DownloadStringCompleted += this.DownloadStringCompleted;
                wc.DownloadStringAsync(new Uri("http://www.chicagocodecamp.com/api/Sessions/" + EventId + "?json=true", UriKind.RelativeOrAbsolute));
            }
        }
开发者ID:paaschpa,项目名称:ChicagoCodeCamp,代码行数:27,代码来源:Sessions.xaml.cs

示例15: RegisterUser

 public void RegisterUser(string Name)
 {
     Uri xmlUri = new Uri(srvStr + "AddUser?u=" + Name);
     WebClient uFeed = new WebClient();
     uFeed.DownloadStringCompleted += new DownloadStringCompletedEventHandler(uFeed_DownloadStringCompleted);
     uFeed.DownloadStringAsync(xmlUri);
 }
开发者ID:astubbs,项目名称:datacom-2010-devcamp-projects,代码行数:7,代码来源:MainPage.xaml.cs


注:本文中的System.Net.WebClient.DownloadStringAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。