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


C# System.Net.Http.HttpClient.Dispose方法代码示例

本文整理汇总了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();
     }
 }
开发者ID:cartermp,项目名称:core-docs,代码行数:22,代码来源:NetworkClient.cs

示例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;
//.........这里部分代码省略.........
开发者ID:tobias2016,项目名称:OKHOSTING.UDG.Radio,代码行数:101,代码来源:PodcastsController.cs

示例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;
        }
开发者ID:tobias2016,项目名称:OKHOSTING.UDG.Radio,代码行数:33,代码来源:VirtualesController.cs


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