473,387 Members | 1,497 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,387 software developers and data experts.

fire timer event

BC
Hi all,

I have two classes: TransactionCollection and Transaction, where
TransactionCollection is used to store Transaction objects.

public class TransactionCollection : CollectionBase
{
public TransactionCollection()
{
}

public void Add(Transaction transaction)
{
List.Add(transaction);
}
}
public class Transaction
{
private int _transactionID;
private Timer _expireTime;

public Transaction()
{
_expireTime = new Timer();
}

public int TransactionID
{
set{ _transactionID = value; }
}

public void Start()
{
_expireTime.Interval = 3000;
_expireTime.Start();
_expireTime.Tick += new EventHandler(CancelTransaction);
}

private void CancelTransaction(object sender, EventArgs e)
{
Console.WriteLine("cancel transaction...);
}
}

Now in my main method (application start), I created a transaction
object with transaction ID and timer, then added it to the transaction
collection class:

TransactionCollection tc = new TransactionCollection();
Transaction t= new Transaction();
t.TransactionID = 1;
t.Start();
tc.Add(t);

Im expecting the transaction objects in the transaction collection class
will fire the timer event (CancelTransaction) respecting to it's
_expireTime.Interval (i.e. every second in this example).

However the transaction object event is never fired up. What did I
missed in the codes? What can I do to make sure the event fire?
Cheers,

Benny

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #1
1 2007
BC
I had solved this problem. I used the wrong timer class.

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #2

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

Similar topics

13
by: Manuel Lopez | last post by:
I have a puzzling form timer problem that I didn't experience prior to Access 2003 (though I'm not sure access 2003 is to blame). Here's the situation: a computer has two access 2003 databases on...
10
by: Wayne Aprato | last post by:
I have a database that was written in Access 2003 using the Access 2000 file format. When I run the mdb in Access 2003 everything works fine. If I run it in Access 2000 the timer event won't fire...
3
by: sanjana | last post by:
hi i want to fire an event if the screen saver starts up i have done it using a timer tick event where i have used the api function to detect if screensaver has started..but this means continuous...
2
by: Besta | last post by:
Hello all, I am having trouble creating a windows service with a timer. Everything seems to go ok but the elapsed event does not fire.Can anyone shed any light on this, may be something simple as...
10
by: SStory | last post by:
I have an aspx page that is used to control automated tasks. It needs to be visited every day at 1am. The host provider provides no such service at present. I was looking for ideas. Thanks...
5
by: Nathan Sokalski | last post by:
I am trying to learn how to use the System.Timers.Timer control to perform an action every certain amount of time. However, the Elapsed event doesn't want to fire, but I can't figure out why. I...
7
by: Noozer | last post by:
I have a timer on a form. It isn't firing at all. I know that the timer is enabled, and that the interval is low (4000, which should be 4 seconds). To ensure the timer wasn't being inadvertantly...
7
by: Jayyde | last post by:
Is there any way to accomplish this? The forms _Load event fires off several other small ones that I'd like to track time for. I can't get either the Mdi Parent form's timer _Tick event or the...
5
by: Jac | last post by:
Hey, I have a windows service and when the day change (so at midnight) I want fire an event so I can execute some code. Do someone has an idea to do that? I don't see directly a solution...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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...
0
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...

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.