I’m trying to get the constructor of an object to initialize a field to something, pause for 30 seconds, and then set it to something else afterwards.
Here is my code:
namespace Practice
{
public enum TransactionStatus { Pending, Complete }
public class Transaction
{
private TransactionStatus status;
public Transaction()
{
this.status = TransactionStatus.Pending;
//(I'm trying to set this to TransactionStatus.Complete after 30 seconds. What do I do afterwards?)
}
// Here is the method to do it... Am I right to think that.status this must be reset this.status in the constructor?
public TransactionStatus SetStatus()
{
// sleep for 30 seconds and then proceed.
System.Threading.Thread.Sleep(3000);
return TransactionStatus.Complete;
}
}
Here’s an alternative cheating method since you said you’re using toString();