Hi I am developing a web application in c#, i have to call a static method defined in the Global Class which having access to few Com objects.in this case do i need to protect the Com object ?
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.
That depends on whether the objects that you are using are shared between threads or not. If you create the objects locally in the method, you don’t need to synchronise them.
However, depending on what COM object you are using, they might have some limitations. If the object is accessing something that can only be used by one thread at a time, you would have to synchronise the threads so that you only create one instance of the object at once.