I'm trying to translate this into C# code:
Wait 5 seconds and then debit the bank account.
I've got a feeling I'm close... but this isn't working. Am I doing this the right way?
public override void Process(BankAccount b, decimal amount)
DateTime present = DateTime.Now;
DateTime addFiveSeconds = DateTime.Now.AddSeconds(5);
if (present != addFiveSeconds)
this.Status = TransactionStatus.Pending;
this.Status = TransactionStatus.Complete;
I think above answer has flaw, it hangs up the main thread , in most case, it is dangerous. You should start a new thread for this delay task, in the thread proc, sleep 30 seconds and then do the work in second thread.