/// <summary> /// if <see cref="CreatedForm"/> is true, then destroys created form. Resets <see cref="CreatedForm"/>, <see cref="TargetForm"/> and <see cref="TargetRichTextBox"/> to default values /// </summary> private void DetachFromControl() { if (CreatedForm) { try { if (!TargetForm.IsDisposed) { if (TargetForm.InvokeRequired) { TargetForm.BeginInvoke((FormCloseDelegate)TargetForm.Close); } else { TargetForm.Close(); } } } catch (Exception ex) { InternalLogger.Warn(ex.ToString()); if (LogManager.ThrowExceptions) { throw; } } CreatedForm = false; } TargetForm = null; TargetRichTextBox = null; }
protected override void CloseTarget() { if (CreatedForm) { try { TargetForm.Dispatcher.Invoke(() => { TargetForm.Close(); TargetForm = null; }); } catch { } } }