If I want to use a bit of unsafe code inside a very time sensitive app – will be there any delay in ‘swiching’ to unsafe code or thread context switch? C# .net 4
Share
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 principle: no. The whole point is that you bypass some of the managed runtime checks and restrictions.
That said, it is theoretically possible that the JIT engine can apply fewer optimizations in rare circumstances, due to the fact that fewer assumptions can be made about the code in the unsafe block. Edit Actually the point about pinning heap memory made by Matthew is a prime example that lies in this direction. The JIT-ter and GC engine are more restricted and can make fewer assumptions
Also, unsafe code requires running with certain permissions so it might not be appropriate for all deplyoment targets.