200 以上の winForms を持ち、次のような entityContext を使用する巨大な HIS アプリケーションの速度とリソース使用量を改善しています。
private void someMethod()
{
var context = new entityContext();
var qry = context.someTable.Where(x=>x.condition);//bring thousands of records
...
... do some thing with result
...
//EOF method. here is problem :
/*
* is context will be free all the records that brings to ram
* in the end of method without using context.Dispose()?
* i think NO!
*/
}
フォームで作成されたすべての entityContext オブジェクトを見つけて破棄する方法はありますか?
winForms Closed イベントで使用するthis.Dispose(true);
と、それらすべてを破棄するだけで十分ですか?
public class myForm : System.Windows.Forms.Form
{
protected override void OnClosed(EventArgs e)
{
base.OnClosed(e);
/*
* TODO:
* find all entityContext objects and dispose them
*/
this.Dispose(true);
}
}
entityContext
すべてのコードを編集して、すべてのオブジェクトをusing{}
句でラップしたり、手動で追加したりする時間はありませんcontext.Dispose()
...
これらが可能な場合に備えて、それらすべてを処分する方法を探していOnClosed()
ますか?