473,804 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

callback or threading or something else ?


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

foundOrNot = doSomeWastingTi meThing(); // 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 doSomewastingTi meThing( ) will spend us a lot of
time.
We want to do the other things till doSomeWastingTi meThing get the
return value (foundOrNot).
When doSomeWastingTi meThing 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-

Nov 14 '05 #1
1 1125
"jiing" <ji********@gma il.com> wrote:
Since we know that doSomewastingTi meThing( ) will spend us a lot of
time.
We want to do the other things till doSomeWastingTi meThing get the
return value (foundOrNot).
When doSomeWastingTi meThing 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.progr ammer 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
Nov 14 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
4182
by: Francois De Serres | last post by:
Hiho, could somebody please enlighten me about the mechanics of C callbacks to Python? My domain is more specifically callbacks from the win32 API, but I'm not sure that's where the problem lies. Here's a description... I want a callback-based MIDI input/processing, so PortMidi was not an alternative. I have written a C extension module that links to the mmsys MIDI API. I separated the win32-dependant code from the Python extension...
1
3649
by: Mohamed Fysal | last post by:
I have written a Regular DLL with many Export Functions and one CALLBACK fun ction . The callback function declared in the .cpp file of the Regular DLL is as fol lows: typedef BOOL (CALLBACK* ExProcessMessage)(UINT msg, LPVOID lpParam); // ExProcessMessage MyProcMsg;
3
5135
by: David | last post by:
Hi, Ive been trying to work this out for the past 2 days now and im not getting anywhere fast. The problem i have is that i am using Asynchronous sockets to create a Socket Client library. When i try to connect to a server that doesnt exist it raises a "Connection forcibly rejected by the resmote host" SocketException.
4
1779
by: Zach | last post by:
(1.) What is the general meaning of the term 'callback'? (2.) What does 'callback' mean, as used in the context of threading? Many thanks, Zach.
2
1773
by: Marten Van Keer | last post by:
Hi; I have two applications A and B *** Application B listens on a network stream with a callback function:
5
1776
by: greg.merideth | last post by:
I have a class that I've provided an event for to be called when the processing in the class is complete (a callback). The class spins up a series of threads for the background operation and I'm firing the callback delgate from within one of the new threads. So far, all is well but I'm curious as to what, threading wise, is going on there. I'm instantiating the class in the app thread (say 1) and providing a method to call when...
11
1987
by: The Frog | last post by:
Hi all, Maybe I am just missing something simple here, but I seem to have an issue with a callback function in A97 that is used to fill a Listbox with values. The first time the callback function is used (when the form opens) all runs well and everyone is happy. Then comes the problem - values are added to the recordset (ADO) that the callback function uses to populate the listbox. After the new values are added to the recordset, the...
2
2072
by: billsahiker | last post by:
I wrote a test program to help understand asynchronous calls in c#. I have a working VB.NET app that uses a similar technique but I cannot get it to work in c#. The errors I get and the code below. I understand the need for threading when updating UI and the general concept of what is going on but do not understand the two errors.: Error 1 'testwinform.Form1.WorkDoneDelegate()' must declare a body because it is not marked abstract or...
4
2947
by: Curious | last post by:
Hi, I have a timer object that's launched as below: mTimer = new System.Threading.Timer (new TimerCallBack(SubscribeTrade), null, 15000, 15000); void SubscribeTrade (object state) { DateTime now = DateTime.Now;
0
10595
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10343
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10335
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10088
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9169
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7633
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5668
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4306
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.