开发者

asp.net threads: attributable to the user that started them

(asp.net 2.0, C#)

I need to implement threading that will be:

  1. Attributable to the user that started the thread (e.g. on a callback, I could use an ID or the name of a thread to look up the thread that the user previously started).
  2. If the thread is finished, the callback should be able to look up the thread and know it is finished.
  3. Finally, the thread would need to automatically terminate if it is active for, say, more than a minute.

I've read quite a bit and I now k开发者_运维百科now that I need to personally manage the threads (e.g. I can't use the asp.net thread pool) because of requirement (1) I listed above. I notice that the Thread class in C# has an ID property; can that ID be used to implement requirement (1) (I don't know if that ID will always be unique, etc)?

Btw, I understand that asp.net can terminate threads at certain points. Basically, any time the user's Session is wiped out, my thread is useless anyway. If the thread does fail or does get terminated for whatever reason, that's fine because the task will be restarted. Mostly I'm concerned with finding some way where the user can look up the thread that was started .. can this be accomplished by storing the ID property in Session? Also, if so, how do I go about using that property to actually find the thread? If not, what is the recommended way to do what I'm asking. Thanks.


IIS will identify the ASP.Net threads for you. You don't need to manage threads on your own. You may need to adjust your authentication method (link 1) or explicty place an IPrincipal object into HttpContext.User (link 2)

IIS Blog

MSDN article

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜