Pelles C forum

C language => Beginner questions => Topic started by: sp00n on May 04, 2007, 10:46:14 AM

Title: About threads
Post by: sp00n on May 04, 2007, 10:46:14 AM
As I'm noob, i want to ask all: How can I realise the treatment of a button, when in the application in that time works another function?
For example:
void Loop()
{
while (true);
}
static LRESULT CALLBACK MainDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
// checking the buttons
}
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpszCmdLine, int nCmdShow)
{
  Loop();
}

I want to check buttons state when Loop() executes:)
Please explaine me this moment.
Title: Re: About threads
Post by: frankie on May 04, 2007, 11:03:35 AM
Run the buttons checking routine in another thread.
To create and start a new thread look in the help for '_beginthread' function.
Title: Re: About threads
Post by: sp00n on May 04, 2007, 11:17:02 AM
Quote from: frankie on May 04, 2007, 11:03:35 AM
Run the buttons checking routine in another thread.
To create and start a new thread look in the help for '_beginthread' function.
Thanks but which lib containes this macros/function? (I know the "process.h", but linker needs a lib-file:) )
Title: Re: About threads
Post by: frankie on May 07, 2007, 12:58:33 PM
Take a look in the PellesC help. It is part of C runtime. The help also give you reference for the win32 API native function.
Moreover you'll find how to create and run a new thread in my webserver code available in the user contribution section (http://www.smorgasbordet.com/forum/index.php?topic=726.0 (http://www.smorgasbordet.com/forum/index.php?topic=726.0))