I have an application which need to check db for every 30secons to check a particular record has updated or not. I use background thread for that. The problem is memory usage of application is continuously increase when I check it in memory profiler. Here is the code
Form1:Base
Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(Check));
t.IsBackground = true;
t.Start();
public void Check() {
bool isUpdate = false;
while (!isUpdate)
{
DataTable _data = CheckRecord();
if (_data.Rows.Count > 0)
{
isUpdate = true;
}
else
{
Thread.Sleep(30000);
}
}
}
public DataTable CheckRecord(){
return CHANNEL.GetData();
}
Form1 inherit base form
Base:Form
ChannelFactory<ServiceClass> temp= new ChannelFactory<ServiceClass>("AAA");
ServiceClass ss=null;
public ServiceClass CHANNEL
{
get {
if(ss==null)
ss=temp.CreateChannel();
return ss;
}
}