Click here to Skip to main content
15,846,144 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
HI ALL

I want to know how to apply multithreading locking technique on
dll is created in vc6

i call it in c#

i want to apply multithreaded locking technique on this dll
when i lock thos its not working like multithreaded
its work like a single thread
plz Help

Thanks in advance
Regards
Posted
Comments
Sergey Alexandrovich Kryukov 19-Sep-12 20:36pm    
If the DLL is in VC6 (why 6?) how it can be relevant to C#. This is C or C++ question. And windows API. If you tell me your ultimate goals, the reason you use two languages in development and other relevant detail, I'll explain how to do the locking.
You might need to use CriticalSection or Mutex object via Windows API. You can lock outside the call on .NET side, but this is not so reliable, if there is a chance that someone would call DLL functions directly, bypassing your C# level.
--SA
BobJanova 21-Sep-12 5:14am    
What does 'multithreaded locking technique' even mean? As Sowraaj points out, locking sections of code forces them into single threaded behaviour.

If I understood the question, you are trying to implement the locking in C# code.
To do this you can use a Mutex[^]
A simple usage would look like this, but please make sure you read the details and the article on MSDN about this, as mutex locking can lead to quite hard to find problems if you make a mistake.
C#
class Example
{
    private static Mutex m = new Mutex();

    public static void DoSomething()
    {
        m.WaitOne();
        //Your code
        m.ReleaseMutex();
    }
}


If this was not what you were looking for, please clarify your question.
 
Share this answer
 
yes , locking the method only allows a single thread to execute, its better to try thread-pool of c#
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900