How do I set the user identity for tasks when calling Task.WaitAll()?

前端 未结 2 1963
南方客
南方客 2020-12-06 12:12

I\'m having a problem invoking WCF services in parallel. I\'m trying to use Tasks to invoke two services in parallel to save some time (I\'m NOT trying to make this async),

2条回答
  •  孤街浪徒
    2020-12-06 13:09

    You might want to look into whether setting is appropriate:

    Specifies that the Windows identity always flows across asynchronous points, regardless of how impersonation was performed.

    By default, this setting is off within ASP.Net, and so the tasks (running, potentially, on other threads) end up just running with no impersonation in place.

    Otherwise (if it's not appropriate to set that), I think you could capture the WindowsIdentity object into a local variable that's captured by the Tasks, and then call Impersonate() on it from within the task. (although I haven't tried this)

提交回复
热议问题