This question is for the .NET Framework 4
Is anyone aware of a way to force the compiler to generate an error when a given instance method makes any calls that block the thread. I am working in a body of code and would like a mechanical way to make sure that nothing in the execution chain will block the thread.
I have been trying to find a property I can add to a method declaration but have not been able to find anything.
When I use the word block I didn’t mean just any code that may hang. Specifically some of the Microsoft api calls like SMTP.Send() and NetworkStream.Read() will stop execution until a specific event is reached.
use FxCop SDK to write your own code analysis rule , set the message level to Error so that whenever the rule is violated it will show up as “compile error” , take a look at this blog for more information Custom Code Analysis Rules