Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how to use thread

how to use thread

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialcomhelp
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cancerion
    wrote on last edited by
    #1

    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

    O E T 3 Replies Last reply
    0
    • C cancerion

      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

      O Offline
      O Offline
      Owner drawn
      wrote on last edited by
      #2

      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 thread AfxEndThread()//to clean up a thread. And take a look at the CWinThread 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:

      1 Reply Last reply
      0
      • C cancerion

        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

        E Offline
        E Offline
        Eytukan
        wrote on last edited by
        #3

        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]--

        1 Reply Last reply
        0
        • C cancerion

          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

          T Offline
          T Offline
          ThatsAlok
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups