本文介绍了“Thread(oxabc)已经退出代码0x0”的多个副本“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这实际上是一个多部分问题,其中心是我在程序中多次创建一个线程(不是同时),并且每次都很快就完成了。当我在运行一段时间后退出主程序时,我似乎得到了

线程已经退出代码(0x0)

每次启动线程的消息。



这可能看起来不是什么大不了的事,但我可能会在程序运行期间运行这段代码20-30K次,所以它显然可以节省很多某处的信息。我的意图是该程序将触发该线程,它将运行,退出,所有被释放然后它可以再次运行。



我也认为我可能正在接近问题不正确,我愿意接受建议。



我有一个机器人视觉(立体声)系统,它有一个旋转轴,电机在每个旋转角度触发一个摄像头触发器。两个摄像头正在等待触发,摄像头驱动程序在抓取图像时调用回调函数进行响应(两个摄像头同时抓取)。

摄像机的回调调用CreateThread,线程复制图像数据,进行一些处理并存储图像数据。我在一个帖子中这样做,因为有必要将程序松开以处理下一个相机抓取。



电话看起来像这样:

 {
...
HANDLE MyHandle;
DWORD MyThreadId;
MyHandle = CreateThread(NULL,NULL,ProcessImageThreadFunc,NULL,NULL,&(MyThreadID));
...
}



无符号 __stdcall ProcessImageThreadFunc( void  * pContext)
{
int cntr = 0 ;
int ndx = PathArray-> mImageRingNdx;

// 此部件等待,直到两个相机处于抓取状态 - 应该是darned
// 近同步 - 只有摄像头2调用CreateThread,因此摄像头1已经
// 捕获了一张图片,或者对此次电话会议很热。

while ((PathArray-> mImgGrabbed [ndx]!= 3 )& ;&(cntr < 2000000 ))
cntr ++;

GrabProc-> mFirstImgGrabbed = 0 ;

StatDlg-> UpdateStatusDisplay(1 | 16 | 32);

GrabProc-> CheckForLastImage( 0 ,ndx);

return 0 ;
}





一段时间后,当我完成所有我需要做的事情并且程序退出时,我得到了很多

线程(0x123)退出代码(0x0)

消息。 (0x123)部分对于每一行都是不同的。



我是不是正确地放弃了MyHandle或MyThreadID?



我不应该用线程做这个吗?



谢谢

解决方案

This is really a multi-part question which centers around the fact that I create a thread multiple times in my program (not simultaneously) and it runs to completion very quickly each time. When I exit the main program quite after running for a while I seem to get the
Thread has exited with code (0x0)
message for each time the thread was started.

This may not seem a huge deal, but I potentially run this chunk of code 20-30K times during the run of the program, so it is obviously saving lots of information somewhere. My intention was that the program would fire the thread, it would run, exit, all be freed and then it could run again.

I also think I may be approaching the problem incorrectly and am open to suggestions.

I have a robotic vision (stereo) system which has a rotational axis and the motor fires a camera trigger every degree of rotation. Two cameras are waiting for the trigger and the camera driver responds by calling a Callback function when an image is grabbed (both cameras grab at the same time).
The callback for the cameras calls CreateThread and the thread copies the image data, does some processing and stores the image data. I do this in a thread because it is necessary to turn the program loose to handle the next camera grab.

The call looks something like this:

{
...
HANDLE MyHandle;
DWORD  MyThreadId;
MyHandle = CreateThread(NULL, NULL, ProcessImageThreadFunc, NULL, NULL, &(MyThreadID));
...
}


unsigned long __stdcall ProcessImageThreadFunc(void *pContext)
{
    int cntr = 0;
    int ndx  = PathArray->mImageRingNdx;

    // This part waits until both cameras are in a grabbed state - should be darned
    // near simultaneous - only camera 2 calls CreateThread, so camera 1 has already
    // captured an image or is hot on the heals of this call.

    while( ( PathArray->mImgGrabbed[ndx] != 3 ) && ( cntr < 2000000 ) )
        cntr++;

    GrabProc->mFirstImgGrabbed = 0;

     StatDlg->UpdateStatusDisplay(1|16|32);

    GrabProc->CheckForLastImage( 0, ndx );

    return 0;
}



Some time later, when I have done all I need to do and the program exits, I get LOTS of
Thread (0x123) has exited with code (0x0)
messages. The (0x123) part is different for each line.

Am I not letting go of the MyHandle or MyThreadID properly or something?

Should I not be doing this with a thread?

Thanks

解决方案


这篇关于“Thread(oxabc)已经退出代码0x0”的多个副本“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 12:35