私のコードは 4 つの関数を実行して、次のようなクラスに (Invoke を使用して) 情報を入力します。
class Person
{
int Age;
string name;
long ID;
bool isVegeterian
public static Person GetPerson(int LocalID)
{
Person person;
Parallel.Invoke(() => {GetAgeFromWebServiceX(person)},
() => {GetNameFromWebServiceY(person)},
() => {GetIDFromWebServiceZ(person)},
() =>
{
// connect to my database and get information if vegeterian (using LocalID)
....
if (!person.isVegetrian)
return null
....
});
}
}
私の質問は、彼が菜食主義者でない場合、null を返すことはできませんが、すべてのスレッドを停止し、処理を停止して null を返すことができるようにしたいということです。どうすれば達成できますか?