在用
线程调用dll的时候就出现
错误。但是直接调用run方法就不会有
问题。请大侠赐教
void MyThread::run()
{
while(true)
{
ThreadProcess();
}
}
void MyThread::ThreadProcess()
{
LPDWORD *cardNum = new LPDWORD;
QLibrary mylib("201Comm.dll");
readCard read=(readCard)mylib.resolve("ReadCardSN");//从
串口读卡号
if(mylib.load())
{
usleep(150);
if(handle==INVALID_HANDLE_VALUE)
{
qDebug()<<tr("串口打开失败");
}
if(read(handle,MachNo,*cardNum) !=1)
{
qDebug()<<123456789<<MachNo;
}
else
{
int tempInt = **cardNum;
QString temp=
QString::number(tempInt)+":"+QString::number(MachNo);
qDebug()<<temp<<"-------------";
}
}
else
{
qDebug()<<tr("缺少2o1Com.dll");
}
delete cardNum;
}
-------------------------------------------------------------
线程启用代码如下
---------------------------------------------------------------
m = new MyThread;
m2 = new MyThread;
m->handle = this->handle;
m2->handle = this->handle;
m->MachNo = 0;
m2->MachNo = 2;
m->start();
m2->start();
m->wait();
m2->wait();
------------------dll说明------------------