Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions HW-Async&Thread-1/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,23 @@ public int NewVal
set
{
// TODO 2:修改操作
val = value;
// 在变化后立即开始计算
Update().Wait();
}
}

public override async Task Update()
{
// TODO 3:更新操作
if (parent != null) await parent.Update();
}

public override void Register(Expr parent)
{
// TODO 4:注册操作
this.parent = parent;
parent.Update();
}
}

Expand Down Expand Up @@ -116,10 +122,14 @@ public AddExpr(Expr A, Expr B)
public override async Task Update()
{
// TODO 6:更新操作
val = ExprA.Val + ExprB.Val;
if (parent != null) await parent.Update();
}

public override void Register(Expr parent)
{
// TODO 7:注册操作
this.parent = parent;
parent.Update();
}
}