C# Task 並列プログラミング .NET Framework 4.0
Task.Factory.StartNew()
に処理を記述- 次の処理がある場合、
ContinueWith()
で繋ぐ
Usage
public Task<JsonResult> GetSomthing(FormCollection collection)
{
var list = new List<Sample>();
return Task.Factory.StartNew(() =>
{
var id = collection["id"];
list = GetModels(id);
}).ContinueWith(t =>
{
return new JsonResult() { Data = list, MaxJsonLength = Int32.MaxValue };
});
}