How to seperate process reading dta from hardware and rendering

Hi everybody
I was developing a simulation system which I developed a 3d scenery and there’ll be an external hardware to control the interaction with the scenery.
My problem is, when I read data from the comunication port(rs232) the FPS for my application will termendously dropped and my application become so slow. So I realize that if only threading can solve my problem which I 'll put the reading process in a thread so that it will not affect the rendering process. But unfortunately, I never done threading before. Can anybody lend me a hand about my problem?
Thank you so much.

Najib

//go to C++ command line in project settings
//and change key /ML on /MT that means
//multi-threading
//include process header
#include ‘process.h’
//must be angular brackets instead of ’
//site administrator do not allow angular
//brackets
//
//you start your thread by function, where
//ServerOn is name of your function (or thread)
WaitForSingleObject((HANDLE)_beginthreadex(NULL, 0, ServerOn, (void*)"", 0, NULL), 0);

//function ServerOn must look like that
unsigned int WINAPI ServerOn(void* dummy) {
for (int i=0; i’less than’10; i++) {
Sleep(1000);
printf("my thread is running
");
}
return 0;
}
//this is thread without passing parameters.
//If you want to learn how to pass
//parameters to thread and
//return something e-mail me directly
//my site is www.graitler.com

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.