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.
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#..
gavra.
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 }
Last edited by eXeCuTeR; 09-18-2008 at 01:41 AM.
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#.
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.