Since this is a C# board, I would imagine he would want to use the lock identifier instead of pinvoking pthread_mutex_lock() function. There is also a mutex class in the .NET framework.
Printable View
Since this is a C# board, I would imagine he would want to use the lock identifier instead of pinvoking pthread_mutex_lock() function. There is also a mutex class in the .NET framework.
@_@
eXeCuTeR
So I guess I should only use pthread_mutex_trylock() and pthread_mutex_unlock() right?
and I need something like this for C#..
using the pthread_mutex_lock() and pthread_mutex_unlock() is just like a lock block.
e.g:
BTW, someone had mentioned it but anyways...beware of deadlocks - they are sometimes really hard to recognize and can really drive you crazy.Code:C: (pthread.h)
pthread_mutex_lock();
// some code
pthread_mutex_unlock();
C#: (System.Threading)
lock(...)
{
// some code
}
Also note that the C# lock properly unlocks itself when an exception is cast, unlike if you'd translate that C-code directly to C#.