Re: Message between threads
- From: "Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT com>
- Date: Thu, 25 May 2006 10:07:41 -0700
That's the wrong way to do it. You have a graphics thread. That should be
the main thread, not a separate thread created by you manually with
CreateThread. I'm unclear on why you have a GUI thread when *you don't have
a GUI*!
Paul T.
"wceess" <wceess@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:A5B33F3F-6384-4A98-90FE-CDEAA02E6368@xxxxxxxxxxxxxxxx
Hi Paul,
I have pasted my code. I would really appreciate if u could take a look at
it.
#define WM_COMMUNICATION_STATUS 2000
DWORD graphics_thread(LPVOID lpv)
{
MSG msg;
WaitForSingleObject(algorithm_event, 100);
while (GetMessage(&msg,Hwndmain, 0, 0))
{
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
//Sleep(100);
return 0;
}
DWORD communication_thread(LPVOID lpv)
{
short int j = 0;
while(TRUE)
{
EnterCriticalSection(&csObject1);
for(int i=0; i <=TARGET_TRACKS; i++)
{
target_track[i].data = j++;
if(j == 10)
j=0;
}
Failure_Status = FALSE;
Failure_Id = 0;
LeaveCriticalSection(&csObject1);
PostMessage(Hwndmain,(UNIT)WM_COMMUNICATION_STATUS,(WPARAM)Failure_Status,(LPARAM)Failure_Id);
}
SetEvent(algorithm_event);
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,int nCmdShow)
{
HANDLE comm_thread;
HANDLE graphic_thread;
DWORD comm_threadid;
DWORD graphic_threadid;
Hwndmain = (HWND) hInstance;
InitializeCriticalSection(&csObject1);
algorithm_event = CreateEvent(NULL, FALSE, FALSE, NULL); // auto reset
comm_thread = CreateThread(NULL,
0,
(LPTHREAD_START_ROUTINE)communication_thread,
(LPVOID*)&csObject1,
0,
&comm_threadid);
graphic_thread =
CreateThread(NULL,0,
(LPTHREAD_START_ROUTINE)graphics_thread,(LPVOID*)&csObject1,0,&graphic_threadid);
CeSetThreadPriority(comm_thread, HIGH_PRIORITY);
CeSetThreadPriority(graphic_thread, LOW_PRIORITY);
while (TRUE)
{
RETAILMSG(3, (_T("-- \n")));
Sleep(1000);
}
DeleteCriticalSection(&csObject1);
return 0;
}
.
- References:
- Re: Message between threads
- From: Paul G. Tobey [eMVP]
- Re: Message between threads
- From: Steve Maillet \(eMVP\)
- Re: Message between threads
- From: Paul G. Tobey [eMVP]
- Re: Message between threads
- From: wceess
- Re: Message between threads
- From: wceess
- Re: Message between threads
- Prev by Date: Re: Connecting Windows CE 4.0 to a Windows Server 2003
- Next by Date: Re: SMSC LAN9118 driver with PXA270
- Previous by thread: Re: Message between threads
- Next by thread: Re: Message between threads
- Index(es):
Relevant Pages
|