void Load () { var monitor = loadMonitor; System.Threading.ThreadPool.QueueUserWorkItem (delegate { try { HttpWebRequest req = (HttpWebRequest) HttpWebRequest.Create (url); WebResponse resp = req.GetResponse (); MemoryStream ms = new MemoryStream (); using (var s = resp.GetResponseStream ()) { s.CopyTo (ms); } var data = ms.ToArray (); MonoDevelop.Ide.DispatchService.GuiSyncDispatch (delegate { Gdk.PixbufLoader l = new Gdk.PixbufLoader (resp.ContentType); l.Write (data); image = l.Pixbuf; l.Close (); monitor.Dispose (); }); // Replace the async operation to avoid holding references to all // objects that subscribed the Completed event. loadOperation = NullAsyncOperation.Success; } catch (Exception ex) { loadMonitor.ReportError (null, ex); Gtk.Application.Invoke (delegate { monitor.Dispose (); }); loadOperation = NullAsyncOperation.Failure; } loadMonitor = null; }); }
void Load() { var monitor = loadMonitor; System.Threading.ThreadPool.QueueUserWorkItem(delegate { try { HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url); WebResponse resp = req.GetResponse(); MemoryStream ms = new MemoryStream(); using (var s = resp.GetResponseStream()) { s.CopyTo(ms); } var data = ms.ToArray(); MonoDevelop.Ide.DispatchService.GuiSyncDispatch(delegate { Gdk.PixbufLoader l = new Gdk.PixbufLoader(resp.ContentType); l.Write(data); image = l.Pixbuf; l.Close(); monitor.Dispose(); }); // Replace the async operation to avoid holding references to all // objects that subscribed the Completed event. loadOperation = NullAsyncOperation.Success; } catch (Exception ex) { loadMonitor.ReportError(null, ex); Gtk.Application.Invoke(delegate { monitor.Dispose(); }); loadOperation = NullAsyncOperation.Failure; } loadMonitor = null; }); }
private Gdk.Pixbuf GetPixbuf(ByteVector data) { bool bail = false; Gdk.Pixbuf output; Gdk.PixbufLoader loader = new Gdk.PixbufLoader(); try { if (!loader.Write(data.Data)) { bail = true; } } catch { bail = true; } try { if (!loader.Close()) { bail = true; } } catch { bail = true; } output = (!bail) ? loader.Pixbuf : null; return(output); }
public override Gdk.Pixbuf Load () { // FIXME this is a hack. No, really, I mean it. byte [] data = GetEmbeddedJpeg (); if (data != null) { Gdk.PixbufLoader loader = new Gdk.PixbufLoader (); loader.Write (data, (ulong)data.Length); Gdk.Pixbuf pixbuf = loader.Pixbuf; loader.Close (); return pixbuf; } return null; }
public override Gdk.Pixbuf Load() { // FIXME this is a hack. No, really, I mean it. byte [] data = GetEmbeddedJpeg(); if (data != null) { Gdk.PixbufLoader loader = new Gdk.PixbufLoader(); loader.Write(data, (ulong)data.Length); Gdk.Pixbuf pixbuf = loader.Pixbuf; loader.Close(); return(pixbuf); } return(null); }
private void Close() { ThumbnailGenerator.Default.PopBlock(); try { result = null; delay.Stop(); if (loader != null) { loader.AreaPrepared -= ap; loader.AreaUpdated -= au; // this can throw exceptions loader.Close(); } } catch (System.Exception) { //System.Console.WriteLine (e.ToString ()); if (pixbuf != null) { pixbuf.Dispose(); } pixbuf = null; } finally { if (loader != null) { loader.Closed -= ev; loader.Dispose(); } loader = null; if (stream != null) { stream.Close(); } stream = null; } }