CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2009
    Posts
    24

    Anyone to ensure functions get run consecutively (and not simultaneously)?

    I'm working on a project right now, and I've got 6 functions that I want to run in the main. They all do what they're supposed to do, and I've all got them outputting each of their steps to a log file for testing purposes.

    Anyway, I've noticed that, although all the functions are called in order, they don't quite seem to be executing the way I want them to. I'd like for function 2 only to start when function 1 ends. I suppose I could call function 2 at the end of function 1, but just wanted to know if there was another way to go about doing this.

    Note: Within these 6 functions, other functions are also being called. I'm not sure if that will affect anything.

    Thanks in advance for any help you can offer.

  2. #2
    Join Date
    Jun 2008
    Posts
    2,477

    Re: Anyone to ensure functions get run consecutively (and not simultaneously)?

    They are being run in serial, your code has a bug in it which is making you think otherwise. The compiler doesn't generate code that jumps around randomly. Code in a thread is executed in serial.

  3. #3
    Join Date
    Dec 2003
    Location
    Northern Ireland
    Posts
    1,362

    Re: Anyone to ensure functions get run consecutively (and not simultaneously)?

    unless the main thread is kicking off async stuff in other threads. Really no way to know without seeing any code.
    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rich Cook


    0100 1101 0110 1001 0110 0011 0110 1000 0110 0001 0110 0101 0110 1100 0010 0000 0100 0101 0110 1100 0110 1100 0110 0101 0111 0010

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured