开发者

Sharepoint webpart multithread when debugging?

I've developed a webpart that presents a strange behaviour. When I load the page where is instal开发者_JAVA技巧led sometimes it works correctly and sometimes it crashes, but I can't find any pattern (seems random to me).

When I debugged it I saw that have two threads of execution. (The cursor of debug always passes two times over every function in separated threads). How can it be?

I want that only be one thread, and I also suspect that this could be the source of the random crash. Any idea where start to find this error?

EDIT:

Added the two screenshots with the debug

Sharepoint webpart multithread when debugging?

Sharepoint webpart multithread when debugging?


That is the problem with threads and shared variables, if you don't synchronize you never know when things crash. First off you have to find why you get more threads accessing your code, If you can not "remove" the behavior you will have to synchronize the access to all the variables that are shared in you object using locks or some other synchronizing mechanisms. (Be relay careful that you do not get any deadlocks doing that).

The point here is. If you are not able to make the code run in a single tread, you have to synchronize the access to the variables in the object so things will not crash.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜