モデルを構築するには、2つのwcf呼び出しを行う必要があります
[SecurityOperationBehavior]
public Response1 Func1(Request1 req)
{
}
[SecurityOperationBehavior]
public Response2 Func2(Request2 req)
{
}
TaskCompletionSourceを使用して、両方の呼び出しが終了するまで待つ必要があることを理解しています。
public FullResult GetResult(int id)
{
Request1 req = new Request1 ();
req.id = id;
Request2 req2 = new Request2 ();
req2.id = id;
var taskCompletions = new[]
{
new TaskCompletionSource<object>(),
new TaskCompletionSource<object>()
};
var tasks = new[] { taskCompletions[0].Task, taskCompletions[1].Task };
System.Threading.Tasks.Task.Factory.StartNew(()=>Func1(req );
System.Threading.Tasks.Task.Factory.StartNew(()=>Func2(req2 );
System.Threading.Tasks.Task.WaitAll(tasks);
//the following is what I want to do. The results of the
//two service calls will be contained in the the full result
FullResult result = new FullResult();
result.first = tasks[0].Result;
result.second = tasks[0].Result;
return Result;
}
問題:
両方のサービスコールが終了した後に結果を設定するにはどうすればよいですか?