473,408 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Make a synchronous call using asynchronous function

!NoItAll
297 100+
There appears to be lots of information about how to asynchronously implement synchronous functions - however I have the opposite problem and there is a dearth of information about it...
I have a network lib I am using. All calls are asynchronous - that's good. However, I need to make SOME calls synchronously - in that I want the program (or at least the current thread) to stop and wait for the response (or time out). This is for things like filling in a form for a user to read and make selections...
There are all kinds of ways such as a simple spinwait
Expand|Select|Wrap|Line Numbers
  1. Dim sw as new Stopwatch
  2. sw.start
  3. Do until bsomething = true or sw.elapsedmilliseconds >= TIMEOUT
  4.      Threading.thread.sleep(25)
  5.      Application.DoEvents
  6. Loop
  7. If sw.Elapsedmilliseconds > TIMEOUT then
  8.    'notify user of timeout
  9. Else
  10.    'process the data that arrived inside the asyc function
  11. End if 
  12.  
Maybe this is acceptable, but it seems hacky to me. For one, it requires two global variables - the boolean (bsomething in the example above) and a global to hold the data that arrived asynchronously. Is there a pattern others use for these things?
Is this a place where a callback makes sense (I've not done any callbacks yet...)?
Sep 13 '16 #1
0 898

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Randell D. | last post by:
Folks, I feel like pulling my hair out - I tried unsuccessfully over the past few days to install ImagMagick but because of version conflicts and missing libraries I had to give up. I originally...
17
by: Patrick | last post by:
I am almost certain that I could use HTTP Post/Get to submit XML Web Service call (over SSL as well, if using Version 3 of MSXML2) from an ASP Application? However, would I only be able to call...
1
by: ahmed fat-hi | last post by:
hi every body to make a call using TAPI i do the following: 1- initiate connectiion 2- Select an Address 3- make a call when i make a call i execute the function ITAddress::CreateCall the...
1
by: Robert | last post by:
Vb.Net Make dll that contain one function. Help Please. I would like to call a function from different applications. I think i have to make a dll. I have Visual Basic.net 2003 Standard...
4
by: Ivan | last post by:
how to make a single method thread safe? example: class A { void func() {} } thread1: A a1 = new A();
3
by: KaNos | last post by:
Hi, "robot script pages" are html+javascript pages, can be played in aspx player. So in this tech, robot call aspx player's function (an interface is sheared) and wait a result synchronously with...
11
by: Fabio | last post by:
Hi all There is a way to exec a function asynchronously? I need to exec a function that is too slow but for me can be executed in the background... there is no way??? Thanks
1
by: bsonline | last post by:
I want to make a call from my JSP page using Web Service. So for that I need a third party. Is this possible to make call ??
2
by: SpecialKay | last post by:
Im getting this error when i try to make a call to a function, from inside an event hook. Anyone have some suggestion on things to try? thanks a lot
4
by: kp7796 | last post by:
What is synchronous function? What is asynchronous function? Unsigned char a=0; Void function (void ){ Unsigned char Flag; Flag=0 If (a==1){ Flag=1; }
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.