CallContext vs ThreadStatic

前端 未结 2 830
情歌与酒
情歌与酒 2020-11-29 02:31

What are differences between CallContext and ThreadStatic?

I\'ve understood that in an ASP.NET environment data stored in CallContext could be persisted throughout t

相关标签:
2条回答
  • 2020-11-29 03:12

    Very often a request will use the same thread throughout, but it certainly won't always be the case - ASP.NET exhibits thread agility. There's an old in-depth blog article about the matter from 2005, but as of .NET 4.5 things are rather better.

    0 讨论(0)
  • 2020-11-29 03:30

    Items stored as ThreadStatic are available to more than one request. IIS reuses the thread after a request is complete to process subsequent requests, it can even swap a request from one thread to another during processing. ASP.Net clears down the CallContext after each request.

    0 讨论(0)
提交回复
热议问题