private void Application_Exit(object sender, ExitEventArgs e) { using (var ni = this._ApplicationBuis as IDisposable) { using (var kh = this._KeyboardHook as IDisposable) { this._KeyboardHook = null; this._ApplicationBuis = null; this._ApplicationModel = null; } } }
private void initApplication() { if (this._ApplicationModel == null) { var applicationModel = this.TryFindResource("ApplicationModel") as TNDApplicationModel; var notifyIconBuis = PoorMansDI.Instance.Create <ITNDNotifyIconBuis>().Init(applicationModel); var applicationBuis = PoorMansDI.Instance.Create <ITNDApplicationBuis>().Init(applicationModel, notifyIconBuis); var keyboardHook = PoorMansDI.Instance.Create <ITNDKeyboardHook>().Init(applicationModel); applicationModel.Init(applicationBuis); this._ApplicationModel = applicationModel; this._ApplicationBuis = applicationBuis; this._KeyboardHook = keyboardHook; this.Resources.Add("ApplicationBuis", applicationBuis); } }