Thread: Threading

  1. #16
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    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.

  2. #17
    Registered User gavra's Avatar
    Join Date
    Jun 2008
    Posts
    265
    @_@

    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.

  3. #18
    Registered User
    Join Date
    Oct 2007
    Posts
    242
    Quote Originally Posted by gavra View Post
    @_@

    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:
    Code:
    C: (pthread.h)
    pthread_mutex_lock();
    // some code
    pthread_mutex_unlock();
    
    C#: (System.Threading)
    lock(...)
    {
     // some code
    }
    BTW, someone had mentioned it but anyways...beware of deadlocks - they are sometimes really hard to recognize and can really drive you crazy.
    Last edited by eXeCuTeR; 09-18-2008 at 01:41 AM.

  4. #19
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. c++ threading
    By Anddos in forum C++ Programming
    Replies: 4
    Last Post: 12-28-2005, 03:29 PM
  2. C++ Threading?
    By draggy in forum C++ Programming
    Replies: 5
    Last Post: 08-16-2005, 12:16 PM
  3. Problem with threading
    By osal in forum Windows Programming
    Replies: 6
    Last Post: 07-21-2004, 12:41 PM
  4. starting to learn multi threading
    By hanhao in forum C++ Programming
    Replies: 2
    Last Post: 06-09-2004, 01:44 PM
  5. Threading
    By threads in forum C# Programming
    Replies: 0
    Last Post: 01-17-2003, 11:50 PM