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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Syncronisation problem

Syncronisation problem

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestioncareer
5 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.
  • V Offline
    V Offline
    VCProgrammer
    wrote on last edited by
    #1

    Hi all, I am having a problem. I am having two threads, one thread i doing some work inside a for loop and inside that for loop its making a call for second thread. My problem is that my first thread should not resume its working untill thread2 finishes it work, and after thread2 has finished its work it should start its working after thread2 was called. Can i use CEvent for this??? I am not getting how to do it. Thanks in advance

    M L T 4 Replies Last reply
    0
    • V VCProgrammer

      Hi all, I am having a problem. I am having two threads, one thread i doing some work inside a for loop and inside that for loop its making a call for second thread. My problem is that my first thread should not resume its working untill thread2 finishes it work, and after thread2 has finished its work it should start its working after thread2 was called. Can i use CEvent for this??? I am not getting how to do it. Thanks in advance

      M Offline
      M Offline
      Malli_S
      wrote on last edited by
      #2

      Have a look at this[^] for basic usage of event object. You can use the same logic to use CEvent on you own. You may find this[^] code project article useful too.

      [Delegates]      [Virtual Desktop]      [Tray Me !]
      -Malli...! :rose:****

      1 Reply Last reply
      0
      • V VCProgrammer

        Hi all, I am having a problem. I am having two threads, one thread i doing some work inside a for loop and inside that for loop its making a call for second thread. My problem is that my first thread should not resume its working untill thread2 finishes it work, and after thread2 has finished its work it should start its working after thread2 was called. Can i use CEvent for this??? I am not getting how to do it. Thanks in advance

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Sounds like a good time to use WaitForSingleObject() in the first thread, waiting for an event or some other object to get notified/released/set in the second thread.

        ============================== Nothing to say.

        1 Reply Last reply
        0
        • V VCProgrammer

          Hi all, I am having a problem. I am having two threads, one thread i doing some work inside a for loop and inside that for loop its making a call for second thread. My problem is that my first thread should not resume its working untill thread2 finishes it work, and after thread2 has finished its work it should start its working after thread2 was called. Can i use CEvent for this??? I am not getting how to do it. Thanks in advance

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          VCProgrammer wrote:

          my first thread should not resume its working untill thread2 finishes it work

          So why are you using threads? This is serial processing not parallel, so using threads does not provide any advantage.

          Programming is work, it isn't finger painting. Luc Pattyn

          1 Reply Last reply
          0
          • V VCProgrammer

            Hi all, I am having a problem. I am having two threads, one thread i doing some work inside a for loop and inside that for loop its making a call for second thread. My problem is that my first thread should not resume its working untill thread2 finishes it work, and after thread2 has finished its work it should start its working after thread2 was called. Can i use CEvent for this??? I am not getting how to do it. Thanks in advance

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

            VCProgrammer wrote:

            Can i use CEvent for this???

            yes you can! however am agree with richard!

            "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
            Never mind - my own stupidity is the source of every "problem" - Mixture

            cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You

            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