特定の時点の値をタスクに渡す、または凍結する方法は?
以下のコードの問題は、DocFTSinXsCollection(SID) に渡される SID は、次の rdr.Read() からの SID ではなく、Task.Factory.StartNew が実行されたときではありません。
while (rdr.Read())
{
SID = rdr.GetInt32(0);
// other code
Task.Factory.StartNew(() =>
{
// this often gets the new SID - I need the SID from when Task was started
DocFTSinXsCollection docFTSinXsCollection = new DocFTSinXsCollection(SID);
}
// other code
}