473,509 Members | 10,100 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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



//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();

}
Nov 15 '05 #1
2 2462
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

"Montaque" <mo******@citiz.net> wrote in message
news:eI****************@TK2MSFTNGP12.phx.gbl...
//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();

}
Nov 15 '05 #2
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

"Montaque" <mo******@citiz.net> wrote in message
news:eI****************@TK2MSFTNGP12.phx.gbl...
//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();

}
Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
15684
by: andrewcw | last post by:
I am trying to do a windows service with C#. I am using as a base the VB.NET article in VS, but I thing the WITHEVENTS timer notation is a delegate. Can anyone provide sample code & anh hints. ...
0
317
by: Montaque | last post by:
//Refersh the datagrid automatically.however,the callback function test() is not been invoked. any suggestions? the following lists the code private void AutoRefreshData() {...
4
1539
by: - R | last post by:
Hello all. I'm new to .Net so please help me out. I have a application with several "Threads" running to observe various things. From time to time each thread need to add an log entry, which...
6
2836
by: Dan | last post by:
I've created a pocketpc app which has a startup form containing a listview. The form creates an object which in turn creates a System.Threading.Timer. It keeps track of the Timer state using a...
3
5955
by: mjheitland | last post by:
Hi, I like to know how many threads are used by a Threading.Timer object. When I create a Threading.Timer object calling a short running method every 5 seconds I expected to have one additional...
4
14378
by: Lauren Quantrell | last post by:
I have just put together a vb.net app and now need to provide it to users. This application needs to run the code in a sub every 60 seconds from a Windows Service application. I have the...
10
12692
by: DaTurk | last post by:
Hi, I'm creating an application that will need to use a timer to do a static method call every second. My question, is what would be the best timer to use? I know there are several, but I'd...
8
9363
by: Lemune | last post by:
Hi, I'm developing window service application on C# 2005. The service is to read a new excel file on certain directory, and process it to database. The service work find on XP. But when I...
3
3849
by: Steve | last post by:
Hi All I am using VB.net 2008 and use timer controls within my applications Question Does the code in a Timer control.tick event run on a different thread to the main Application thread (UI...
0
7237
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7347
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7416
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7073
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5062
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3218
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3207
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1571
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
779
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.