What is the use of Thread.BeginThreadAffinity() method in Thread class ?
It will be helpful for me to understand if you provide its sample example with exaplaination.
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In .NET 1.x, a Thread was always matched with an operating system thread. At the request of the SQL Server team, that association was broken for .NET 2.0. A CLR host can now take control of thread mapping itself, the IHostTaskManager is the work-horse interface for that. There’s a good backgrounder in this blog post.
Sometimes code really does care that it runs on a particular operating system thread. Windows critical sections and mutants would be an example. Really, any kind of unmanaged code interop. Thread.BeginThreadAffinity() invokes IHostTaskManager::BeginThreadAffinity() to let the host know that the task should not be allowed to run on another operating system thread but stick on the one it is currently on, until EndThreadAffinity() is called.
But, don’t worry about any of this. The SQL Server project was a bust, they couldn’t get it reliable. There have been no signs that they’ll try again.