public override NSImage GetScreenshot() { NSAutoreleasePool pool = new NSAutoreleasePool(); try { if (CurrentScreenshot != null) { CurrentScreenshot.Release(); CurrentScreenshot = null; } NSImage img = null; if (m_sessionViewController != null) { img = m_sessionViewController.GetScreenshot(); } if (img != null) { CurrentScreenshot = img.Retain <NSImage>(); } } catch (Exception ex) { ApiUtils.Log.Add(new RoyalLogEntry() { Severity = RoyalLogEntry.Severities.Debug, Action = RoyalLogEntry.ACTION_PLUGIN, PluginName = PLUGIN_NAME, PluginID = PLUGIN_ID, Message = "Error while getting screenshot", Details = ex.ToString() }); } finally { if (pool != null) { pool.Drain(); pool = null; } } return(CurrentScreenshot); }