本文整理汇总了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);
}
}
示例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);
}
示例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);
}
}
示例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));
}
示例5: GetVEServiceKey
private void GetVEServiceKey()
{
WebClient wc = new WebClient();
wc.DownloadStringCompleted += this.WebClientDownloadStringCompleted;
Uri keyURI = new Uri(URIHelper.CurrentApplicationURL, "VEKey.txt");
wc.DownloadStringAsync(keyURI);
}
示例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)));
}
示例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);
}
}
示例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);
}
示例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));
}
示例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);
}
}
示例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);
}
示例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;
}
示例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"));
}
}
示例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));
}
}
示例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);
}