开发者

calling a static method from multiple thread, do we need to use the syncronization mechanishm?

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 ?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜