Hi all,
I have two classes: TransactionColl ection and Transaction, where
TransactionColl ection is used to store Transaction objects.
public class TransactionColl ection : CollectionBase
{
public TransactionColl ection()
{
}
public void Add(Transaction transaction)
{
List.Add(transa ction);
}
}
public class Transaction
{
private int _transactionID;
private Timer _expireTime;
public Transaction()
{
_expireTime = new Timer();
}
public int TransactionID
{
set{ _transactionID = value; }
}
public void Start()
{
_expireTime.Int erval = 3000;
_expireTime.Sta rt();
_expireTime.Tic k += new EventHandler(Ca ncelTransaction );
}
private void CancelTransacti on(object sender, EventArgs e)
{
Console.WriteLi ne("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:
TransactionColl ection tc = new TransactionColl ection();
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 (CancelTransact ion) respecting to it's
_expireTime.Int erval (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 ***
I have two classes: TransactionColl ection and Transaction, where
TransactionColl ection is used to store Transaction objects.
public class TransactionColl ection : CollectionBase
{
public TransactionColl ection()
{
}
public void Add(Transaction transaction)
{
List.Add(transa ction);
}
}
public class Transaction
{
private int _transactionID;
private Timer _expireTime;
public Transaction()
{
_expireTime = new Timer();
}
public int TransactionID
{
set{ _transactionID = value; }
}
public void Start()
{
_expireTime.Int erval = 3000;
_expireTime.Sta rt();
_expireTime.Tic k += new EventHandler(Ca ncelTransaction );
}
private void CancelTransacti on(object sender, EventArgs e)
{
Console.WriteLi ne("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:
TransactionColl ection tc = new TransactionColl ection();
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 (CancelTransact ion) respecting to it's
_expireTime.Int erval (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 ***
Comment