473,385 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 2459
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
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
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
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
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
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
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
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
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
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.