Im trying to make a Non-Blocking Server/Client Program using Winsock and Im trying to create threads to handle the blocking functions.
I was wondering, how do I actually set up a simple thread?
If anybody knows of an example that uses Threading, in C if possible, Id greatly appreciate it.
Basically i just need a skeleton app that demonstrates starting/creating a thread on the click of a button, and then ending/destroying that thread on the click of another button.
I have a basic layout but i have no idea what to do, Ive tried but my programs take up 100% of my CPU and It takes me 10 minutes of clicking on the X button to close them.
Code:
Winmain()
{
...
}
Winproc()
{
case WM_COMMAND:
{
switch(HIWORD(wParam))
{
case BN_CLICKED:
{
switch(LOWORD(wParam))
{
case START_THREAD:
{
//code here to start thread
break;
}
case STOP_THREAD:
{
//code here to stop thread
break;
}
}
break;
}
}
break;
}
}
void Thread1()
{
//Lets say it make the titlebar scroll
}
void Thread2()
{
//Lets say it make the titlebar flash
}
I just need someone to fill in the blanks (more or less), and if possible can you show an example of setting up 2 threads at the same time.