I have a method which returns DataSet from postgressql database.
ds = stats.loadStats();
I need to update DataSet randomly, once in 3 minutes (for example).
Random r = new Random();
var rendom_number = r.Next(0, 179);//3 minutes = 3*60 = 180 sec.
if (rendom_number == 1)
{
//reload Dataset here
}
once event is triggered - I need to dispose of the old Dataset and update it with the new one, without causing overloads, memory leaks, or other troubles. How do you do it with C#?
there are three methods that I know of, but which is the best?
method
ds.Clear(); //disposing of old DataSet ds = stats.loadStats(); //loading new
method
ds.Dispose(); //disposing of old DataSet ds = stats.loadStats(); //loading new
method
ds = null; //disposing of old DataSet ds = stats.loadStats(); //loading new
what's your method? (or the best option)