本文整理汇总了C#中System.Net.Http.HttpClient.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# System.Net.Http.HttpClient.Dispose方法的具体用法?C# System.Net.Http.HttpClient.Dispose怎么用?C# System.Net.Http.HttpClient.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.Http.HttpClient
的用法示例。
在下文中一共展示了System.Net.Http.HttpClient.Dispose方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakeRequestAndLogFailures
// </HandleNotChanged>
// <AwaitFinally>
public static async Task<string> MakeRequestAndLogFailures()
{
await logMethodEntrance();
var client = new System.Net.Http.HttpClient();
var streamTask = client.GetStringAsync("https://localHost:10000");
try {
var responseText = await streamTask;
return responseText;
} catch (System.Net.Http.HttpRequestException e) when (e.Message.Contains("301"))
{
await logError("Recovered from redirect", e);
return "Site Moved";
}
finally
{
await logMethodExit();
client.Dispose();
}
}
示例2: Start
public override void Start()
{
base.Start();
IRelativePanel panel = Platform.Current.Create<IRelativePanel>();
panel.BackgroundColor = new Color (255, 255, 255, 255);
IGrid grdMenu = Constantes.CrearMenuVacio();
panel.Add(grdMenu, RelativePanelHorizontalContraint.LeftWith, RelativePanelVerticalContraint.TopWith);
IImageButton imgHome = Platform.Current.Create<IImageButton>();
imgHome.LoadFromUrl (new Uri("http://radioudg.okhosting.com/images/app-15.png"));
imgHome.Click += cmdHome_Click;
grdMenu.SetContent(1, 0, imgHome);
IImageButton imgRegionales = Platform.Current.Create<IImageButton>();
imgRegionales.LoadFromUrl (new Uri("http://radioudg.okhosting.com/images-old/icon-11.png"));
imgRegionales.Click += cmdEstaciones_Click;
grdMenu.SetContent(1, 1, imgRegionales);
IImageButton cmdProgramas = Platform.Current.Create<IImageButton>();
cmdProgramas.LoadFromUrl (new Uri("http://radioudg.okhosting.com/images-old/icon-08.png"));
//cmdProgramas.Click += (object sender, EventArgs e) => new ProgramasController().Start();
grdMenu.SetContent(1, 2, cmdProgramas);
IImageButton imgVirtuales = Platform.Current.Create<IImageButton>();
imgVirtuales.LoadFromUrl (new Uri("http://radioudg.okhosting.com/images-old/icon-09.png"));
imgVirtuales.Click += cmdVirtuales_Click;
grdMenu.SetContent(1, 3, imgVirtuales);
ILabel lblTitulo = Constantes.CrearTitulo("Archivo de programa", new Color(255, 255, 143, 0));
panel.Add(lblTitulo, RelativePanelHorizontalContraint.LeftWith, RelativePanelVerticalContraint.BelowOf, grdMenu);
if (Platform.Current.Page.Width > 250)
{
IImage imgLogo = Platform.Current.Create<IImage> ();
imgLogo.LoadFromUrl (new Uri ("http://radioudg.okhosting.com/images-old/icon2--14.png"));
imgLogo.Width = Platform.Current.Page.Width / 6;
imgLogo.Height = lblTitulo.Height;
imgLogo.Margin = new Thickness (0, 0, 10, 0);
panel.Add(imgLogo, RelativePanelHorizontalContraint.RightWith, RelativePanelVerticalContraint.TopWith, lblTitulo);
}
System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
var xmlStream = client.GetStreamAsync(Show.PodcastUri).Result;
System.Xml.XmlReader reader = System.Xml.XmlReader.Create(xmlStream);
IList<Episode> episodios = new List<Episode>();
//extraer episodios del xml
while (reader.ReadToFollowing ("item"))
{
reader.ReadToFollowing ("title");
Episode episodio = new Episode ();
episodio.Name = reader.ReadElementContentAsString ();
reader.ReadToFollowing ("link");
string mp3string = reader.ReadElementContentAsString();
episodio.EpisodeUri = new Uri (mp3string);
episodio.ImagenUri = Show.LogoUri;
episodio.Description = Show.Name;
episodios.Add (episodio);
}
reader.Dispose();
xmlStream.Dispose();
client.Dispose();
IControl referencia = lblTitulo;
foreach (Episode episodio in episodios)
{
IImageButton imgLogo = Platform.Current.Create<IImageButton>();
imgLogo.LoadFromUrl(Show.LogoUri);
imgLogo.Click += Episode_Click;
imgLogo.Tag = episodio;
imgLogo.Width = Constantes.AnchoIconos;
imgLogo.Height = Constantes.AnchoIconos;
//set margin for first iteration
if (referencia == lblTitulo)
{
imgLogo.Margin = new Thickness(10, 10, 10, 10);
}
else
{
imgLogo.Margin = new Thickness(0, 10, 10, 10);
}
panel.Add(imgLogo, RelativePanelHorizontalContraint.LeftWith, RelativePanelVerticalContraint.BelowOf, referencia);
referencia = imgLogo;
ILabelButton lblNombre = Platform.Current.Create<ILabelButton> ();
lblNombre.Click += Episode_Click;
lblNombre.Text = episodio.Name;
lblNombre.Tag = episodio;
lblNombre.Bold = true;
//.........这里部分代码省略.........
示例3: LeerEstaciones
public static List<Station> LeerEstaciones()
{
List<Station> estaciones = new List<Station>();
System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
var xmlStream = client.GetStreamAsync("http://radioudg.okhosting.com/virtuales.xml").Result;
System.Xml.XmlReader reader = System.Xml.XmlReader.Create(xmlStream);
//extraer episodios del xml
while (reader.ReadToFollowing("estacion"))
{
Station estacion = new Station();
reader.ReadToFollowing("imagen");
estacion.WebSiteUri = new Uri(reader.ReadElementContentAsString());
reader.ReadToFollowing("streaming");
estacion.StramingUri = new Uri(reader.ReadElementContentAsString());
reader.ReadToFollowing("nombre");
estacion.Name = reader.ReadElementContentAsString();
reader.ReadToFollowing("descripcion");
estacion.Description = reader.ReadElementContentAsString();
estaciones.Add(estacion);
}
reader.Dispose();
xmlStream.Dispose();
client.Dispose();
return estaciones;
}