News:

Download Pelles C here: http://www.smorgasbordet.com/pellesc/

Main Menu

About threads

Started by sp00n, May 04, 2007, 10:46:14 AM

Previous topic - Next topic

sp00n

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.

frankie

Run the buttons checking routine in another thread.
To create and start a new thread look in the help for '_beginthread' function.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

sp00n

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:) )

frankie

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)
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide