--- trunk/libxmltv/Core/XMLTVInstance.cs 2013/03/08 03:36:44 44 +++ trunk/libxmltv/Core/XMLTVInstance.cs 2013/03/08 04:01:25 46 @@ -3,13 +3,22 @@ using System.Linq; using System.Text; using libxmltv.Interfaces; +using System.ComponentModel; namespace libxmltv.Core { - internal class XMLTVRuntimeInstance : MarshalByRefObject, IXMLTVRuntimeInstance, IDisposable + internal class XMLTVRuntimeInstance : MarshalByRefObject, IXMLTVRuntimeInstance { - public XMLTVRuntimeInstance(string xmlfile) { CreateInstance(xmlfile); } - private void CreateInstance(string xmlfile) { Instance = new XMLTVInstance(xmlfile, this); } + public XMLTVRuntimeInstance(string xmlfile) : this(xmlfile, null) { } + public XMLTVRuntimeInstance(string xmlfile, EventHandler t) { CreateInstance(xmlfile,t); } + private void CreateInstance(string xmlfile, EventHandler t) + { + CancelEvent = t; + using (Instance = new XMLTVInstance(xmlfile, this)) + { + } + } + internal XMLTVInstance Instance { get; private set; } #region IXMLTV_LOADER members @@ -22,12 +31,35 @@ public Dictionary Programs { get; set; } #endregion - public void Dispose() + //public void Dispose() + //{ + // IsDisposing = true; + // //throw new NotImplementedException(); + //} + //public bool IsDisposing { get; private set; } + + + private event EventHandler CancelEvent = null; + + public bool IsAborting { - IsDisposing = true; - //throw new NotImplementedException(); + get + { + if (CancelEvent != null) + { + CancelEventArgs e = new CancelEventArgs(); + CancelEvent.Invoke(this, e); + if (e.Cancel) + { + xmltv_logger.Log.Verbose.Debug.WriteLine("Detected Instance abort event..."); + } + return e.Cancel; + } + return false; + } } - public bool IsDisposing { get; private set; } + + } internal class XMLTVInstance : IDisposable