确定一个dll是否被应用程序中的多个线程调用-使用ThreadId
Determine if a dll is being called by multiple threads from an application - Use ThreadId?
我创建了一个静态dll文件,供某个应用程序使用。我想知道该dll的导出方法是由该应用程序的单独线程还是由单个线程调用的。我在想,如果我输出调用dll中方法的线程的线程,这可能有助于我弄清楚该函数是由单个线程还是多个线程调用的。这有帮助吗?另外,我将如何得到线程的线程,正在调用dll ?
使用GetCurrentThreadId函数
std::vector<DWORD> ids;
__declspec(dllexport) int __stdcall SomeFunction()
{
DWORD id = GetCurrentThreadID();
if (std::find(ids.begin(), ids.end(), id) != ids.end())
{
// New thread uses this function
ids.push_back(id);
}
}
相关文章:
- 如何声明由多个线程调用的 C++ DLL 的内部类,而无需导出类
- 非静态成员失败的线程调用函数
- 线程调用的函数对对象删除是否安全?
- 将类成员函数作为线程调用到另一个类成员函数时发出警告消息
- 通过 Qt 中的线程调用 Rust 库
- Qt信号和插槽如果从QRunnable或其他线程调用,则不起作用
- 在销毁期间从另一个线程调用对象上调用方法是否未定义行为?
- 由并发无序映射查找线程调用的函数是否安全?
- 如何从另一个线程调用颤振引擎方法
- C++ std::线程调用方法,从对象原因到调用此类的析构函数
- 从多个线程调用 std::shuffle
- std::thread::join() 可以从非父线程调用吗?
- 如何使用 Win32 API 从 Excel VBA 中的非"Single-Threaded Apartment"线程调用 InternetGetProxyInfo
- 带参数的线程调用库函数
- 如何在本机C++中跨线程调用(在主线程上回调)
- 如果两个线程调用同一个函数,但函数中的所有变量都是局部变量,我还需要担心线程之间共享数据吗?
- 优雅断言函数不是从多个线程调用的
- 从第二个线程调用Qt信号有效 - >对连接的插槽没有影响
- 包装标准::线程调用函数
- 从 Visual C++ 2010 中的单独线程调用消息框