Page 1 of 1

Sleep() in main thread

Posted: Tue Feb 01, 2011 3:56 am
by Ushikubo Tomohiro
I'm using V100:R2 camera, and MFC program.

I made program like this.
i) Initializing the cameras in main thread
ii) Making another thread, and getting the camera data by the thread
iii) On OnTimer, using the Sleep(100) command in the main thread

In this program, I can't get camera data in some frame.
Would you tell me advice to solve this problem, and would you tell me the reason why this program doesn't work correct?

Thanks.

Re: Sleep() in main thread

Posted: Tue Feb 01, 2011 3:42 pm
by beckdo
Hey Cat,

This is certainly a valid arrangement for an application that utilizes the Camera SDK.

However, you don't want to put a Sleep() in the OnTimer() function. The goal for an OnTimer() function is to do what you need to do and exit the function. By putting a Sleep(100) in the OnTimer() function you're stalling execution for 1/10th of a second, which is a deal breaker. I would suggest removing the Sleep() function in this case.

This is the opposite of the other situation we discussed where you had a tight While() loop, which requires you put a Sleep() in the function in order to yield to other processes or else you'll drive the CPU to 100% and starve the Camera SDK and other processes.

Re: Sleep() in main thread

Posted: Thu Feb 03, 2011 7:10 pm
by Ushikubo Tomohiro
Thank you for replying ma question.

I tested some condition about getting the camera data by making the another thread.
I found that it can't be get frame, if it isn't executed message dispatching.

Would you tell me how long can the camera wait message dispatching about V100:R2 camera and S250e camera?

Thanks