Dispose() 공개 메소드

public Dispose ( ) : void
리턴 void
예제 #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;
     }
 }
예제 #2
0
        private static ArcGISLegendResponse GetLegendResponseFromWebresponse(WebResponse webResponse)
        {
            var dataStream = webResponse.GetResponseStream();

            if (dataStream != null)
            {
                var sReader = new StreamReader(dataStream);
                var jsonString = sReader.ReadToEnd();

                var serializer = new JsonSerializer();
                var jToken = JObject.Parse(jsonString);
                var legendResponse = (ArcGISLegendResponse)serializer.Deserialize(new JTokenReader(jToken), typeof(ArcGISLegendResponse));

                dataStream.Dispose();
                webResponse.Dispose();

                return legendResponse;
            }

            webResponse.Dispose();

            return null;
        }
        /// <summary>
        /// Process the web response from the server.
        /// </summary>
        protected override void OnWebResponseReceived(WebResponse response)
        {
            LiveLoginResult result;

            bool nullResponse = (response == null);
            try
            {
                Stream responseStream = (!nullResponse) ? response.GetResponseStream() : null;
                if (nullResponse || responseStream == null)
                {
                    result = new LiveLoginResult(
                        new LiveAuthException(AuthErrorCodes.ClientError, ResourceHelper.GetString("ConnectionError")));
                }
                else
                {
                    result = this.GenerateLoginResultFrom(responseStream);
                }
            }
            finally
            {
                if (!nullResponse)
                {
                    response.Dispose();
                }
            }

            this.OnOperationCompleted(result);
        }
예제 #4
0
        private Map parseXMLtoMap(WebResponse xmlResponse)
        {
            try
            {
                using (var contentStream = xmlResponse.GetResponseStream())
                {
                    XDocument load = XDocument.Load(contentStream);
                    var data = from query in load.Descendants("ImageOptions")
                               select new Map
                               {
                                   Name = (string)query.Element("Name"),
                                   Description = (string)query.Element("Description"),
                                   NWLat = (double)query.Element("NWLat"),
                                   NWLong = (double)query.Element("NWLong"),
                                   SELat = (double)query.Element("SELat"),
                                   SELong = (double)query.Element("SELong"),
                                   SWLat = (double)query.Element("SWLat"),
                                   SWLong = (double)query.Element("SWLong"),
                                   NELat = (double)query.Element("NELat"),
                                   NELong = (double)query.Element("NELong"),
                                   ZoomLevel = (int?)query.Element("ZommLevel"),
                                   Transparency = (int?)query.Element("Transparency")
                               };
                    if (data.Count() > 1)
                        this.Log().Debug("Multiple Map XML Elements in content stream");

                    return data.FirstOrDefault();
                }
            }
            finally
            {
                xmlResponse.Dispose();
            }
        }
예제 #5
0
 private static void DisposeOfWebResponse(WebResponse response)
 {
     if (response == null) return;
       response.Close();
       response.Dispose();
 }