Question

In: Computer Science

How can we transform a "synchronous" web method to "asynchronous" web methods?  

How can we transform a "synchronous" web method to "asynchronous" web methods?  

Solutions

Expert Solution

Synchronous versus asynchronous

In Synchronous call, on the off chance that you are making any solicitation, at that point you should hold up till the reaction, you can't do some other thing until you won't get the reaction.

In Asynchronous call, in the event that you are making any solicitation, at that point you don't have to hang tight for the reaction and you can play out some other errand. At whatever point the reaction will come, you can get in get back to designate.

So on the off chance that any solicitation won't require some investment, at that point you can utilize synchronous call else you can utilize nonconcurrent. Or on the other hand on the off chance that you are calling web administration technique in circle (like you need to accomplish something in framework cell), at that point you should utilize synchronous way.

We transform synchrnoys web methods to asynchronous methods as follows :-

There is a BeginXXX and EndXXX web method where XXX is any string that represents the name of the method you want to expose.
The BeginXXX function returns an IAsyncResult interface and takes an AsyncCallback and an object as its last two input parameters,respectively.
The EndXXX function takes an IAsyncResult interface as its only parameter.
Both the BeginXXX and EndXXX methods must be flagged with the Web Method attribute.


Synchronous web method

[WebMethod]

public string Sleep(int milliseconds)
{
Thread.Sleep(milliseconds);
}
Example.Asynchronous web methods
[WebMethod]
public IAsyncResult BeginSleep(
int milliseconds,
AsyncCallback cb,
object s) {...}
[WebMethod]
public string EndSleep(IAsyncResult call) {...}


Related Solutions

what the propagation delay can be on a synchronous and an asynchronous counter that needs to...
what the propagation delay can be on a synchronous and an asynchronous counter that needs to run at 200MHz? Show me how you would calculate this.
Design a mod 5 counter as a (a) synchronous circuit (b) asynchronous circuit
Design a mod 5 counter as a (a) synchronous circuit (b) asynchronous circuit
How can we control the speed of Synchronous an AC Generator and give me a picture...
How can we control the speed of Synchronous an AC Generator and give me a picture of Synchronous an AC Generator regarding of what you are planning to say about controlling the speed? Give me details as much as you can.
(a) What is the difference between synchronous and asynchronous stream ciphers. (b) Who was Horst Feistel?...
(a) What is the difference between synchronous and asynchronous stream ciphers. (b) Who was Horst Feistel? (c) What is the main weakness of affine ciphers? (d) What is the Kerckhoffs’ principle? (e) Suppose a block cipher uses m-to-m bits S-boxes. How many bits are required to store the look-up table of k different such m-to-m bits S-boxes? Give a formula in terms of k and m. Hint: A look-up table for one DES S-box requires 256 bits of storage.
Human Resource Information Management; What is the difference between synchronous and asynchronous training format? What are...
Human Resource Information Management; What is the difference between synchronous and asynchronous training format? What are the key benefits of Web technology in managing the content of knowledge management systems? What service can personalization of knowledge management systems provide? What features of web-based collaboration give it advantages over teleconferencing or videoconferencing? What are the advantages of web-based training/knowledge management?
sir how can we find the tourier transform of the sawtooth wave limits -infinite to +infinite
sir how can we find the tourier transform of the sawtooth wave limits -infinite to +infinite
a)Differences between asynchronous and synchronous generators? Which one applies in the plants and why? b)Where do...
a)Differences between asynchronous and synchronous generators? Which one applies in the plants and why? b)Where do gas and steam turbines apply, not to mention in power plants? c) What are the main components of the wind generator system or solar-batteries-substation? d) What is the difference between using the star or triangle connection at the start of an engine? e) In equipment tests, what is the difference between type, routine and special tests? f) Why are insulated cables not used in...
In method overloading, can we have two or more methods with different parameter name and same...
In method overloading, can we have two or more methods with different parameter name and same datatype? Yes No Clear selection When do we need to do Explicit Casting? When LHS and RHS data types are different When size of LHS variable is bigger than LSH When RHS is an expression and not variable When all values of RHS variable or expression are not valid for LSH variable What data type should be used when we want to store any...
Synchronous and Induction Machine Questions Q1: How do we find induced voltage, frequency, synchronous reactance, generated...
Synchronous and Induction Machine Questions Q1: How do we find induced voltage, frequency, synchronous reactance, generated voltage at pf for a synchronous generator? Q2: How do we find slip and number of poles, speed of rotor, load torque, induced torque in a induction motor? Q3: Based on an induction motor test(no-load, blocked-rotor test)- what are the circuit parameters and how do we draw the circuit? Q4: For a synchronous machine, how do we draw phasor diagram?
Explain in detail the differences between 4-Bit Synchronous and Asynchronous Counters. Each Flip-Flop is negative-edge triggered....
Explain in detail the differences between 4-Bit Synchronous and Asynchronous Counters. Each Flip-Flop is negative-edge triggered. Use the relevant block diagrams, Truth Table of state sequence, and Timing Diagram to support your explanation.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT