System.Net.WebResponse.Dispose C# (CSharp) Метод

Dispose() публичный Метод

public Dispose ( ) : void
Результат void
        public void Dispose() { }
        protected virtual void Dispose(bool disposing) { }

Same methods

WebResponse::Dispose ( bool disposing ) : void

Usage Example

Пример #1
0
 void Image_Change()
 {
     try
     {
         string[] a     = null;
         string[] b     = null;
         int      suiji = intSuijishu(1, 6);
         Task.Run(() =>
         {
             WebClient webClient = new WebClient();
             a = Encoding.UTF8.GetString(webClient.DownloadData("http://106.14.64.250/api/" + suiji + ".html")).Split('#');
             webClient.Dispose();
             b = a[1].Split('|');
             System.Net.WebRequest webreq  = System.Net.WebRequest.Create("http://106.14.64.250/api/" + b[1]);
             System.Net.WebResponse webres = webreq.GetResponse();
             System.IO.Stream stream       = webres.GetResponseStream();
             System.Drawing.Image img1     = System.Drawing.Image.FromStream(stream);
             System.Drawing.Bitmap bmp     = new System.Drawing.Bitmap(img1);
             IntPtr hBitmap = bmp.GetHbitmap();
             this.Dispatcher.BeginInvoke(new Action(() =>
             {
                 ImageLabel1.Content = a[0];
                 ImageLabel.Text     = b[0];
                 Image.Source        = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
             }));
             stream.Dispose();
             webreq.Abort();
             webres.Dispose();
             img1.Dispose();
             bmp.Dispose();
             GC.Collect();
             this.Dispatcher.BeginInvoke(new Action(() =>
             {
                 Image_Loading.Visibility = Visibility.Collapsed;
             }));
         });
     }
     catch
     {
         Image_Loading.Visibility = Visibility.Collapsed;
     }
 }
All Usage Examples Of System.Net.WebResponse::Dispose