我试图让一个对象的构造函数将一个字段初始化为某个东西,暂停 30 秒,然后将其设置为其他东西。
这是我的代码:
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;
}
}