Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Development Edition
 Do not treat fibers as threads
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Visual Studio Team System
Do not treat fibers as threads

TypeName

DoNotTreatFibersAsThreads

CheckId

CA2003

Category

Microsoft.Reliability

Breaking Change

Non Breaking

A managed thread is being treated as a Win32 thread.

Do not assume a managed thread is a Win32 thread - it is a fiber. The CLR will run managed threads as fibers on top of real threads owned by SQL. These threads will be shared across AppDomains and even databases in the SQL Server process. Using managed thread local storage will work, but you may not use unmanaged thread local storage or assume your code will run on the current OS thread again. Do not change settings like the thread's locale. Do not call CreateCriticalSection or CreateMutex via P/Invoke because they require the thread that enters a lock also exit the lock. Because this will not be the case when you use fibers, Win32 critical sections and mutexes will be useless in SQL. You may safely use most of the state on a managed System.Thread object, including managed thread local storage and the thread's current UI culture. However, for programming model reasons, you will not be able to change a thread's current culture when running in SQL ;this will be enforced through a new permission.

Examine your usage of threads and alter your code accordingly.

You should not suppress this rule.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker