fix(legacy): release hosted module resources safely
This commit is contained in:
@@ -174,6 +174,10 @@ namespace Lskj.Control.MultiModelLookUp
|
||||
public bool ReturnCollection;
|
||||
|
||||
#endregion
|
||||
private GridDragGrid _dragGrid;
|
||||
private GridDragGrid _backDragGrid;
|
||||
private bool _dragResourcesDisposed;
|
||||
|
||||
public FrmModelLookUp2(string ModuleCodel)
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -184,8 +188,8 @@ namespace Lskj.Control.MultiModelLookUp
|
||||
this.gcMain.GridControl.ContextMenuStrip = contextMenuStrip1;
|
||||
this.gcMain.GridView.DoubleClick += new EventHandler(OnRowCellClick);
|
||||
this.gcDetail.GridView.DoubleClick += new EventHandler(OnDoubleClick);
|
||||
GridDragGrid dragGrid = new GridDragGrid(this.gcMain.GridView, this.gcDetail.GridView);
|
||||
GridDragGrid backdragGrid = new GridDragGrid(this.gcDetail.GridView, this.gcMain.GridView);
|
||||
_dragGrid = new GridDragGrid(this.gcMain.GridView, this.gcDetail.GridView);
|
||||
_backDragGrid = new GridDragGrid(this.gcDetail.GridView, this.gcMain.GridView);
|
||||
//设置关联模块
|
||||
bool result = SetAssociatedModules();
|
||||
this.pl_top.Height = 0;
|
||||
@@ -210,8 +214,8 @@ namespace Lskj.Control.MultiModelLookUp
|
||||
this.gcMain.GridView.OptionsBehavior.EditorShowMode = DevExpress.Utils.EditorShowMode.MouseDown;
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.OnFormClosing);
|
||||
this.gcMain.GridControl.ContextMenuStrip = contextMenuStrip1;
|
||||
GridDragGrid dragGrid = new GridDragGrid(this.gcMain.GridView, this.gcDetail.GridView);
|
||||
GridDragGrid backdragGrid = new GridDragGrid(this.gcDetail.GridView, this.gcMain.GridView);
|
||||
_dragGrid = new GridDragGrid(this.gcMain.GridView, this.gcDetail.GridView);
|
||||
_backDragGrid = new GridDragGrid(this.gcDetail.GridView, this.gcMain.GridView);
|
||||
//设置关联模块
|
||||
bool result = SetAssociatedModules();
|
||||
|
||||
@@ -1108,13 +1112,50 @@ namespace Lskj.Control.MultiModelLookUp
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
private void DisposeDragResources()
|
||||
{
|
||||
if (_dragResourcesDisposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_dragResourcesDisposed = true;
|
||||
GridDragGrid dragGrid = _dragGrid;
|
||||
_dragGrid = null;
|
||||
if (dragGrid != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
dragGrid.Dispose();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Continue releasing the reverse registration.
|
||||
}
|
||||
}
|
||||
|
||||
GridDragGrid backDragGrid = _backDragGrid;
|
||||
_backDragGrid = null;
|
||||
if (backDragGrid != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
backDragGrid.Dispose();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Drag cleanup must not block form disposal.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnFrmModelLookUp_Disposed(object sender, EventArgs e)
|
||||
{
|
||||
DisposeDragResources();
|
||||
if (this.DataSource != null)
|
||||
{
|
||||
this.DataSource = null;
|
||||
}
|
||||
GC.Collect();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user