callback or threading or something else ?

Discussion in 'C Programming' started by jiing, Apr 15, 2005.

  1. jiing

    jiing Guest

    bool foundOrNot = 0;
    while (! foundOrNot){
    // from here do some calculations here
    ......
    ......
    // till here

    foundOrNot = doSomeWastingTimeThing(); // This function will spend
    a lot of time to get the answer of returnValue
    // do some other calculations here, for example
    ......
    ......
    ......
    // till here
    }


    Since we know that doSomewastingTimeThing( ) will spend us a lot of
    time.
    We want to do the other things till doSomeWastingTimeThing get the
    return value (foundOrNot).
    When doSomeWastingTimeThing return the answer, we begin to do something
    about the returned answer.

    Now, my question is:
    1. How can I do it in C Language? Could you show me some valid code?
    My friend told me that I may use a call back function or thread to
    achieve it. But he never did that before.
    Could someone guide me to the right direction or give me some url or
    examples?
    Thanks in advance.

    -jiing-
    jiing, Apr 15, 2005
    #1
    1. Advertising

  2. jiing

    Richard Bos Guest

    "jiing" <> wrote:

    > Since we know that doSomewastingTimeThing( ) will spend us a lot of
    > time.
    > We want to do the other things till doSomeWastingTimeThing get the
    > return value (foundOrNot).
    > When doSomeWastingTimeThing return the answer, we begin to do something
    > about the returned answer.
    >
    > Now, my question is:
    > 1. How can I do it in C Language?


    You can't; not in C alone. If you are on a Unixoid, or somewhere else
    where POSIX-like threads are available, perhaps comp.unix.programmer can
    give you an answer; if not, your system does probably provide threading,
    but as an extension to ISO C, and you'll need to ask in a newsgroup that
    discusses programming for your compiler and/or OS.

    Richard
    Richard Bos, Apr 15, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest
    Replies:
    4
    Views:
    475
    Guest
    Oct 13, 2004
  2. Replies:
    25
    Views:
    659
    MonkeeSage
    Oct 1, 2006
  3. kj
    Replies:
    15
    Views:
    548
    Lawrence D'Oliveiro
    May 23, 2009
  4. A
    Replies:
    8
    Views:
    795
    James Kanze
    Aug 28, 2010
  5. Replies:
    4
    Views:
    211
    Tad McClellan
    Jun 1, 2007
Loading...

Share This Page