private void button_Click(object sender, EventArgs e) { using (DataTable dt = new DataTable()) { dt.Columns.Add("Name", typeof(string)); using (CheckingPerformance objCheckingPerformance = new CheckingPerformance()) { objCheckingPerformance.method(objCheckingPerformance.method_row(dt)); } } }
public class CheckingPerformance:IDisposable { public DataTable dt = null; public DataRow dr = null; private bool _disposed; public DataTable method(DataTable pdt) { return pdt; } public DataTable method_row(DataTable dt) { for (int i = 0; i <= 200000; i++) { dt.Rows.Add("admin" + i.ToString()); } return dt; } protected virtual void Dispose(bool disposing) { if (!_disposed) { if (disposing) { // Dispose managed resources //if (_stream != null) _stream.Dispose(); if (dt != null) dt = null; if (dr != null) dr = null; } // Dispose unmanaged resources //_handle = IntPtr.Zero; //_stream = null; _disposed = true; } } public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } ~CheckingPerformance() { Dispose(false); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)