using System; namespace MyDownloader.App.SingleInstancing { /// /// Provides a proxy to communicate with the first instance of the application. /// internal class SingleInstanceProxy : MarshalByRefObject { #region Member Variables private ISingleInstanceEnforcer enforcer; #endregion #region Construction / Destruction /// /// Instantiates a new SingleInstanceProxy object. /// /// The enforcer (first instance of the application) which will receive messages from the new instances of the application. /// enforcer is null. public SingleInstanceProxy(ISingleInstanceEnforcer enforcer) { if (enforcer == null) throw new ArgumentNullException("enforcer", "enforcer cannot be null."); this.enforcer = enforcer; } #endregion #region Properties /// /// Gets or sets the enforcer (first instance of the application) which will receive messages from the new instances of the application. /// public ISingleInstanceEnforcer Enforcer { get { return enforcer; } } #endregion /// /// Override and return NULL to prevent windows from doing /// garbage collection on the proxy object. /// public override object InitializeLifetimeService() { return null; } } }