Click here to Skip to main content
16,004,944 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: is there platform-independent FillMemory function in C/C++!? Pin
Joaquín M López Muñoz3-Nov-04 11:06
Joaquín M López Muñoz3-Nov-04 11:06 
QuestionThe fastest bitmap blitting software? Pin
KellyR3-Nov-04 8:55
KellyR3-Nov-04 8:55 
AnswerRe: The fastest bitmap blitting software? Pin
ThatsAlok3-Nov-04 22:23
ThatsAlok3-Nov-04 22:23 
QuestionTwo files are the same? Pin
peterchen3-Nov-04 8:14
peterchen3-Nov-04 8:14 
AnswerRe: Two files are the same? Pin
Joaquín M López Muñoz3-Nov-04 8:33
Joaquín M López Muñoz3-Nov-04 8:33 
AnswerRe: Two files are the same? Pin
David Crow3-Nov-04 9:01
David Crow3-Nov-04 9:01 
GeneralCSplitterWnd Tab Views Pin
asv3-Nov-04 7:26
asv3-Nov-04 7:26 
GeneralHELP strange thread termination Pin
Vladimir Dubovoy3-Nov-04 7:14
Vladimir Dubovoy3-Nov-04 7:14 
Eek! | :eek: Eek! | :eek: Confused | :confused: Mad | :mad: Help please!

I used simple wrapper class for the thread. It is just below.
so method ::Start() is used to run it. So some strange thing
is happening. If I call it inside some method

void MyClass::SomeMethod(){
this->p5dev_engine.Start();
...
}

Thread runs but when SomeMethod() is exited, thread does not run too.
But I need it continue to run.
May be did something in wrong way?

class P5DevEngine{
friend DWORD WINAPI DeviceEngineProc(LPVOID lpParameter);
public:
CRITICAL_SECTION csect;

P5DevEngine();
~P5DevEngine();
void Start();
void Stop();
inline BOOL IsRunning(){return running;}
private:
P5Device* p5;
BOOL running;
HANDLE thread;
int thID;
};

static DWORD WINAPI DeviceEngineProc(LPVOID lpParameter){
P5Device* device=(P5Device*)GetP5Device();
P5DevEngine* engine=(P5DevEngine*)lpParameter;
while(TRUE){
EnterCriticalSection(&engine->csect);
device->Cycle(30);
LeaveCriticalSection(&engine->csect);
::Sleep(30);
}
}

P5DevEngine::P5DevEngine(){
InitializeCriticalSection(&csect);
running=FALSE;
thread=NULL;
}

P5DevEngine::~P5DevEngine(){
DeleteCriticalSection(&csect);
}
void P5DevEngine::Start(){
P5Device* dev=(P5Device*)GetP5Device();
if(!dev->IsInited()) dev->Init();
thread=CreateThread(NULL,1,DeviceEngineProc,(LPVOID)this,0,(LPDWORD)thID);
if(thread)
running=TRUE;
else{
running=FALSE;
Error("Can not run thread");
}
}

void P5DevEngine::Stop(){
if(thread){
TerminateThread(thread,0);
running=FALSE;
}
}
GeneralRe: HELP strange thread termination Pin
Joaquín M López Muñoz3-Nov-04 8:05
Joaquín M López Muñoz3-Nov-04 8:05 
GeneralRe: HELP strange thread termination Pin
Vladimir Dubovoy5-Nov-04 3:49
Vladimir Dubovoy5-Nov-04 3:49 
GeneralWindows Message Question Pin
Tom Wright3-Nov-04 6:54
Tom Wright3-Nov-04 6:54 
GeneralRe: Windows Message Question Pin
Joaquín M López Muñoz3-Nov-04 8:11
Joaquín M López Muñoz3-Nov-04 8:11 
GeneralRe: Windows Message Question Pin
Tom Wright3-Nov-04 10:33
Tom Wright3-Nov-04 10:33 
GeneralRe: Windows Message Question Pin
Joaquín M López Muñoz3-Nov-04 10:53
Joaquín M López Muñoz3-Nov-04 10:53 
GeneralRe: Windows Message Question Pin
Tom Wright3-Nov-04 11:50
Tom Wright3-Nov-04 11:50 
GeneralMemory Allocation error _CrtCheckMemory() Pin
Rassul Yunussov3-Nov-04 6:49
Rassul Yunussov3-Nov-04 6:49 
GeneralMutex problem Pin
anderslundsgard3-Nov-04 5:11
anderslundsgard3-Nov-04 5:11 
GeneralRe: Mutex problem Pin
valikac3-Nov-04 6:12
valikac3-Nov-04 6:12 
GeneralRe: Mutex problem Pin
anderslundsgard3-Nov-04 20:23
anderslundsgard3-Nov-04 20:23 
GeneralRe: Mutex problem Pin
peterchen3-Nov-04 10:16
peterchen3-Nov-04 10:16 
GeneralRe: Mutex problem Pin
anderslundsgard3-Nov-04 20:22
anderslundsgard3-Nov-04 20:22 
GeneralRe: Mutex problem Pin
peterchen3-Nov-04 20:49
peterchen3-Nov-04 20:49 
GeneralRe: Mutex problem Pin
anderslundsgard3-Nov-04 21:37
anderslundsgard3-Nov-04 21:37 
GeneralAudio Sample Rate Interpolation Pin
Anthony98873-Nov-04 4:40
Anthony98873-Nov-04 4:40 
GeneralRe: Audio Sample Rate Interpolation Pin
Alexander M.,3-Nov-04 6:07
Alexander M.,3-Nov-04 6:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.