Automatic Refersh the Datagrid with the timer class in System.Threading

M

Montaque

//Refersh the datagrid automatically.however,the callback function test() is not been invoked. any suggestions?


the following lists the code

private void AutoRefreshData()
{
System.Threading.Timer c=new System.Threading.Timer(new TimerCallback(this.refreshdata),this,0,1000);
}
private void refreshdata(Object Data)
{
this.Invoke(new InvokeFormOwn(this.test));
}

private delegate void InvokeFormOwn();
private void test()
{
this.dataGrid1.DataSource=null;
this.dataGrid1.DataSource=OrderSystem.GetInstance().GetAllOrderItems();

}
 
M

Miha Markic [MVP C#]

Hi,

Is refreshdata invoked?
And you don't need a custom delegate - you might use MethodInvoker.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com



//Refersh the datagrid automatically.however,the callback function test() is
not been invoked. any suggestions?


the following lists the code

private void AutoRefreshData()
{
System.Threading.Timer c=new System.Threading.Timer(new
TimerCallback(this.refreshdata),this,0,1000);
}
private void refreshdata(Object Data)
{
this.Invoke(new InvokeFormOwn(this.test));
}

private delegate void InvokeFormOwn();
private void test()
{
this.dataGrid1.DataSource=null;
this.dataGrid1.DataSource=OrderSystem.GetInstance().GetAllOrderItems();

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top