how to use thread
-
hi , i made an application that can receive a file as unicast and multicast it in dialog based application , but it works only once ,mean to send another file i have to restart the application , so i think using thread i will not require to restart the application , it will receive data as unicast and send it as multicast , plz help me to do it ,if possibe give me an example of code. my id is tosachingupta@gmail.com thanks sachin
-
hi , i made an application that can receive a file as unicast and multicast it in dialog based application , but it works only once ,mean to send another file i have to restart the application , so i think using thread i will not require to restart the application , it will receive data as unicast and send it as multicast , plz help me to do it ,if possibe give me an example of code. my id is tosachingupta@gmail.com thanks sachin
cancerion wrote:
but it works only once ,mean to send another file i have to restart the application
What has threads got to do with it. There must be something wrong with your application design. Well as far as threads are concerned you can use
AfxBeginThread(...)
//for starting off a threadAfxEndThread()
//to clean up a thread. And take a look at theCWinThread
class too.cancerion wrote:
if possibe give me an example of code. my id is tosachingupta@gmail.com
Run
Jesus Loves:rose:
--Owner Drawn:rose: --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord:rose:
-
hi , i made an application that can receive a file as unicast and multicast it in dialog based application , but it works only once ,mean to send another file i have to restart the application , so i think using thread i will not require to restart the application , it will receive data as unicast and send it as multicast , plz help me to do it ,if possibe give me an example of code. my id is tosachingupta@gmail.com thanks sachin
Its simple as that.. (this is a worker for you!) in the header, declare as
UINT Threader(LPVOID p);
void realThread();in the implementation,
UINT YourDialog::Threader(LPVOID p)
{
YourDialog* me = (YourDialog*)p;
me->realThread();
return 0;}
void realThread()
{
do
{
//blabla,..
}while(1);}
then as said by drawn, you can use AfxBeginThread to start the thread ie,
CWinThread *cwt=AfxBeginThread(realThread,this);
cwt->suspend();,cwt->resume();..ect then the thread is under your control :)
0x0400: "But your mind is very complex, very tricky. It makes simple things complicated. -- that's its work. And for centuries it has been trained for only one thing: to make things so complicated that your life becomes impossible."- Osho
--[V]--
-
hi , i made an application that can receive a file as unicast and multicast it in dialog based application , but it works only once ,mean to send another file i have to restart the application , so i think using thread i will not require to restart the application , it will receive data as unicast and send it as multicast , plz help me to do it ,if possibe give me an example of code. my id is tosachingupta@gmail.com thanks sachin
http://www.flounder.com/workerthreads.htm[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV