我对 Lambda 表达式有一个大致的了解,但不确定() =>
语法的含义。此代码似乎返回任务项列表,但我不确定它如何执行或如何解释它的含义。
有人可以告诉我:
- 是什么
() =>
意思? - 似乎每个
new Task
块都是按顺序执行的?
private DateTime? _myTime = null;
private DateTime? _theirTime = null;
private bool _okToProcess = true;
List<Task> myTasks = new List<Task>
{
new Task( () =>
{
_myTime = GetMyTime();
}),
new Task( () =>
{
_theirTime = GetTheirTime();
_okToProcess = _myTime > _theirTime;
}),
new Task(() =>
{
if (_okToProcess)
{
WriteToMyLogStep("We are processing");
}
else
{
WriteToMyLogStep("We are NOT processing");
}
});
};