Listening linux event

Hello,
  am new to linux and I have the following problem:
When I create a function or a thread with an infinite loop my program gets stuck inside the loop and does not listen to incoming messages. In windows i have to write the following code:
MSG message;

1
2
3
4
5
6
7
MSG message;

while(PeekMessage(&message,NULL,0,0,PM_REMOVE))
{
   TranslateMesage(&message);
   DispatchMessage(&message);
}

in linux come fare?
Grazie
Topic archived. No new replies allowed.