本文介绍了MultiThreaded调用VB COM没有性能提升的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 限时删除!! 我已将所有源代码包含在附加的MyTest.zip中 ( http://www.codeguru.com/forum/attach...chmentid=11218 ) 有三个项目: VBTestCOM项目是一个公寓线程DLL,它有一个函数做一个 存储过程调用。这个DLL将从C ++多线程调用。 C ++测试项目是一个ATL多线程DLL,它只是简单创建了 多线程,并调用VBTestCom''每个线程都有doSPCall函数。 VB客户端: 设置线程号并启动一个循环调用C ++ DLL的Do函数。 你需要在SQL Server NorthWind数据库中创建一个存储过程,比如 这个: 创建PROCEDURE dbo.usp_Test AS BEGIN 插入类别(CategoryName,[Description]) values(''CatName'',convert(varchar(30) ,getdate(),9)) WAITFOR延迟''00:00:00.100'' 结束 它创建类别中的记录和延迟100毫秒。 在C ++调试中,更改线程编号,您将看不到性能 的改进。跟踪时间如下: 1线程 vb函数调用时间:109 c ++其他代码时间:62 2线程 vb函数调用时间:156 c ++其他代码时间:62 3线程 vb函数调用时间:256 c ++其他代码时间:62 这令人沮丧!帮助!I have included all the source codes in the attached MyTest.zip(http://www.codeguru.com/forum/attach...chmentid=11218)There are three projects:VBTestCOM project is a apartment threaded DLL, it has one function doing astored procedure call. This DLL will be called from C++ multithread.C++ test project is a ATL multithreaded DLL, it just simple createdmultithread, and call VBTestCom''s doSPCall function in each thread.VB client:It set thread number and start a loop calling C++ DLL''s Do function.You need created a stored procedure in SQL Server NorthWind database likethis:create PROCEDURE dbo.usp_TestASBEGINinsert Categories(CategoryName,[Description])values( ''CatName'', convert(varchar(30),getdate(),9))WAITFOR delay ''00:00:00.100''endIt create a record in Categories and delay 100 milliseconds.In C++ debug, Change the thread number and you will see no performanceimprovement. Trace time in thread like this:1 Threadvb function call time: 109c++ other code time: 622 threadvb function call time: 156c++ other code time: 623 threadvb function call time: 256c++ other code time: 62It''s frustrating! Help!推荐答案 如果VBTestCOM项目是单元线程的(这意味着: 单线程)那么* all *调用此COM -object是序列化的。 所以行为是设计的。 如果你想提高性能,那么切换VBTestCOM 投射到两个或多线程。 - 问候 Jochen 我关于Win32和.NET的博客 http://blog.kalmbachnet。 de / 哪个是不可能使用VB,VB6只能生成单线程 公寓(STA)或单一(在主公寓上实例化)COM DLL'' 。 威利。 - 问候 Jochen 关于Win32和.NET的博客 http://blog.kalmbachnet.de/ 这篇关于MultiThreaded调用VB COM没有性能提升的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的..
09-06 10:53