M
mk
You probably suspect the answer, typically its 'yes'
deadlock can occur in any multithreaded application.
Even ones that employ static members. Commonly it occurs
when more than one thread tries to lock a resource that
another thread has already locked.
A workaround is to use the Monitor object's TryEnter
method, and pass a timeout value, if timeout occurs the
method returns false.
This pattern will save you no end of pain and suffering,
check it out on MSDN. Also I would recommend that you
record the number of deadlock situations (TryEnters that
return false), that occur during your testing -at least
in your debug builds. This may lead you to redefine the
distribution of effort in your application if you find
that contention for resources is undermining efficiency.
Incidentally you may also wish to investigate another
threading bugbear, race conditions, where dirty reads and
overwrites may occur is shared resources are not securely
locked during operations.
HTH,
MK
deadlock can occur in any multithreaded application.
Even ones that employ static members. Commonly it occurs
when more than one thread tries to lock a resource that
another thread has already locked.
A workaround is to use the Monitor object's TryEnter
method, and pass a timeout value, if timeout occurs the
method returns false.
This pattern will save you no end of pain and suffering,
check it out on MSDN. Also I would recommend that you
record the number of deadlock situations (TryEnters that
return false), that occur during your testing -at least
in your debug builds. This may lead you to redefine the
distribution of effort in your application if you find
that contention for resources is undermining efficiency.
Incidentally you may also wish to investigate another
threading bugbear, race conditions, where dirty reads and
overwrites may occur is shared resources are not securely
locked during operations.
HTH,
MK