callback or threading or something else ?

J

jiing

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

Richard Bos

jiing said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top