DLL上的多线程锁定 [英] multithreading locking on dll

查看:131
本文介绍了DLL上的多线程锁定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI ALL

我想知道如何在
上应用多线程锁定技术 dll是在vc6中创建的

我在c#中称它为

我想在此dll上应用多线程锁定技术
当我锁定它不像多线程时那样工作
它的工作就像单线程
请帮助

在此先感谢
关于

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

推荐答案

如果我理解这个问题,则您正在尝试在C#代码中实现锁定. 为此,您可以使用 Mutex [
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.
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.


是的,锁定该方法仅允许单个线程执行,最好尝试使用c#的线程池
yes , locking the method only allows a single thread to execute, its better to try thread-pool of c#


这篇关于DLL上的多线程锁定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆