One-way and asynchronous operations (medium)

Source: Internet
Author: User
ArticleDirectory
    • Asynchronous call of operations in client programs
    • Implement Asynchronous operations in the WCF Service
    • Asynchronous call of operations in client programs
    • Implement Asynchronous operations in the WCF Service

This article from: http://www.cnblogs.com/yang_sy/archive/2011/08/10/2133231.html

 

 

In this scenario, the client Program The service is not expected to return any information. However, many operations do not apply to this situation and return data to the client program. To handle these situations, WCF supports asynchronous operations and the iasyncresult design mode. In WCF, You can implement the iasyncresult design mode in two ways: asynchronously calling operations in the client program; or implementing asynchronous operations in the WCF Service. The iasyncresult design mode is not specifically designed for WCF. It is widely used in. NET Framework. For more details, refer to the "asynchronous programming design mode" of msdn. When using the svcutil command line tool, specify the "/aysnc" flag to generate a specific version of the proxy class. You can also click the Advanced button in the add service reference wizard, and then select the generate Asynchronous Operation check box in the service reference Settings dialog box to generate a proxy class of this specific version. An asynchronous proxy class provides a pair of begin and end methods for each operation. . The client can call the begin method to instantiate the operation. The begin method understands the returned results after sending the request. However, when the. NET Framework is running, a new thread is created on the client to wait for the response of the request. When you call the begin method, you need to provide the name of the callback method. After the service completes the operation and returns the result only as a client proxy, the callback method in the new thread starts to be executed. You can use the callback method to obtain the returned results of the service. You should call the end method of the operation to indicate that you have processed the service response. Understanding this is important later: to support the above asynchronous programming, you do not need to modify the service in any way. In fact, the service itself does not need to be a WCF Service; it may be a service implemented by other technologies. Which makes the operation asynchronous to the client program Code It is encapsulated in the agent object of the client and the. NET Framework runtime. All thread-related problems are handled by the code running in the client's WCF runtime. The Service focuses on the same operations as the exercises in the previous section. Implement Asynchronous operations in the WCF Service using WCF. You can also implement asynchronous operations in the service. In this case, The service provides its own begin and end methods to make up this operation. . The client uses a common operation name to call an operation through a proxy object (the begin method is not used ). Therefore, the client does not have to worry about whether the Service implements this operation asynchronously. Service developers can add the logic to the begin method to select operations that should be performed synchronously or asynchronously by the local user. For example, if the current load of the service is relatively small, you can perform the operation synchronously so that the operation can be completed as soon as possible. If the load increases, the Service may choose to perform operations asynchronously. In this way, you do not need to modify the client program. If the operation returns data to the client after a long time, you should use this method to perform these operations. When defining an operation of a service, set the aysncpattern attribute of the operationcontract feature class to true to specify that the Operation supports asynchronous processing; then, we provide a pair of methods that follow the name conversion and signature described above to implement the iasyncresult design mode. In the following group of exercises, you will add another operation named calculatetotalvalueofstock to the adventureworksadmin service. The purpose of this operation is to determine the current total value of all inventories in the adventureworks warehouse. This operation takes some time to complete. Therefore, you need to use an Asynchronous Method to implement this operation. Exercise: add an asynchronous operation to the adventureworksadmin service. 1. Open the iservice. CS file in the app_code folder in Visual Studio. Add the following operation to the service contract adventureworksadmin. This operation contains two methods: begincalculatetotalvalueofstock and endcalculatetotalvalueofstock. Together, they form a single asynchronous operation called calculatetotalvalueofstock. In this operation, you must use the above naming method to name these two methods. Only in this way can client proxy objects correctly recognize them. You can specify any parameters required for this begin method (in this example, the client program will pass a string parameter to identify the call of the operation ), however, the last two parameters of this method must be an aysnccallback object. This object points to a callback method in the client program, and the other parameter is an object, it holds the State Information provided by the client program. The Return Value of the begin method must be iasyncresult. The end method must receive a single parameter of the iasyncresult type, but its return value should correspond to the return value of the operation. In this example, the calculatetotalvalueofstock operation returns an int type and its value is the calculation result of the total inventory value. Another important part of this operation is the asyncpattern attribute of the operationcontract feature class. You only need to apply the operationcontract feature to the begin method. When you generate the metadata of the service (such as generating a client proxy), this attribute will lead to the implementation of the begin and end as a single asynchronous operation. 2. In the solution window, right-click the app_code folder and select Add saved project. Add the ayncresult. CS file in the Directory D: \ works \ solutions \ WCF \ step. By. Step \ chapter12. 3. Open the aysncresult. CS file and check its content. It contains a generic class named asyncresult, which implements the iasyncresult interface. This class is more detailed than the returned results of this book, but the purpose of the aysncresult class is to provide synchronous methods and status information for other classes that Implement Asynchronous methods. In this exercise, two important members of this class are:
    • The data attribute can read the data returned by an asynchronous operation. In this column, the calculatetotalvalueofstock operation fills in this attribute and returns asyncresult to the client program when the end method is executed.
    • The aysncresult constructor receives two parameters and stores them in the corresponding two private variables. The Service will use the synchronous parameter to specify whether to call the operation synchronously. The statedata parameter will point to the last parameter object passed in the begin method (it is very important to save this object, because the object must return the client program to ensure that the object has been processed)
4. Open the service. CS file in the app_code folder. Then add the following proxy to the adventureworksadmin class. You will use this proxy in the method added later. 5. Add the following method to the adventureworksadmin class. The details of the above method work are beyond the scope of this book (strictly speaking, this method has nothing to do with WCF ). However, in general, this method generates a random number. If this number is an even number, it will execute operations in synchronous mode (simulating low-load scenarios ); otherwise, the operation is performed asynchronously (simulating high-load scenarios ). In the synchronization scenario, the code will create a new asyncresult object. The thread will sleep for 20 seconds to simulate the computing execution time, and then fill the aysncresult object with the number 55555555. In an asynchronous scenario, the Code also creates a new asyncresult object, but a new thread is generated, which slews for 30 seconds in the background. The Code does not fill in the asyncresult object, because when the background sleep thread wakes up, it will fill in the aysncresult object. In both cases, The code will call the callback method in the client program and pass the asyncresult object as the callback method parameter. . The client program receives the calculation result from this object. The callback method will return the same aysncresult object (which is required by the iasyncresult design mode ). This method also displays a message dialog box to help you track the execution of the method and determine whether the operation is synchronous or asynchronous. 6. Add the end method to the adventureworksadmin class. Call the above end method after the begin method is completed. The purpose of this method is to obtain the data attribute value from the passed iasyncresult object (this value is the calculation result of the operation ). If the operation is executed asynchronously, the operation may not be completed yet (the program that calls the in method of an asynchronous operation can call the end method at any time after the begin method ends, therefore, the end method must be completed before it returns ). In this example, the asyncresult object indicates that the method remains in the waiting state until the operation is completed. This method extracts data from asyncresult and returns the data only after the operation is complete. 7. Add the following method to the adventureworksadmin class. If the begin method decides to execute tasks asynchronously, The begin method creates a new thread in the background to simulate and execute the computation. The new thread will sleep for 30 seconds. When the background thread starts to sleep, register the endaysncsleep method as a callback method. 30 seconds later, the operating system activates the background thread and calls this method. This method fills in the Data Attribute of the aysncresult object and indicates that the operation has been completed. This will release the main thread of the service because the main thread is waiting for the end method. After the end method ends, the main thread of the service can return data to the client. Note that the return values of an operation are different, depending on whether the service performs a synchronous operation (returns 55555555) or an asynchronous operation (returns 999999 ). 8. Generate a solution. Exercise: Call calculatetotalvalueofstock In the WCF client. 1. In the adventurewokrsadmintestclient project, expand the service reference folder, right-click the adventureworksadmin service reference, and click Update Service reference. This operation will produce a new version of the client proxy, which includes the calculatetotalvalueofstock operation 2. In the solution browser window, make sure that the check boxes for displaying all files are selected. 3. Expand adventureworksadmin service reference, expand the reference. svcmap folder, and open the reference. CS file. Check the definitions of service contracts in the administrativeservice interface. Note that the new operation named calculatetotalvalueofstock is not marked as begin or end. In fact, this operation is implemented asynchronously and completely transparent to the client program. 4. Edit the program. CS file and delete the generatedailysalesreport and console. writeline statements in the try code snippet. Then add the following code to call the calculatetotalvalueofstock method three times and display the call result. If successful, at least one of these calls of the service is executed in a different way (either synchronous or asynchronous) from the other two ). 5. Running the solution in non-adaptive mode depends on the random number generated by the service. The random number determines whether the operation is performed synchronously or asynchronously. If you are not lucky, you must wait 20 seconds to see the first message prompt box: this is because the random number generated in the calculatetotalvalueofstock method generates an even number, and then the operation will be performed synchronously. The following message prompt box is displayed immediately after the message prompt box is displayed: After you click the confirm button, you will see result 55555555 displayed in the console window of the client program. If you only see the second message prompt box, begincalculatetotalvalueofstock has decided to execute the Asynchronous Method. After you close the message prompt box, you need to wait 30 seconds. You will see the following message prompt box: 999999 will also be displayed in the console window of the client program. Each method that the client program calls the calculatetotalvalueofstock operation repeats the above process. 6. Press enter in the console window of the client program to stop the client. So far, everything has been quite good. You have solved a lot of problems, so that you can allow the Service to determine the best strategy for long execution or resource-consuming creation. However, the client still uses the synchronization method so far. Every time the calculatetotalvalueofstock operation is called, it will be blocked until the operation is completed. Fortunately, you can use the svcutil tool to add/async parameters to generate a proxy that supports asynchronous client operations. This is what needs to be done in the following exercises. Exercise: Call calculatetotalvalueofstock asynchronously in the WCF client program. 1. In the adventurewokrsadmintestclient project, expand the service reference folder, right-click the adventureworksadmin service reference, and click Configure service reference. In the service reference Settings dialog box, select the generate Asynchronous Operation check box, and then click OK. 2. Check the reference. CS file in the reference. svcmap folder. You will see that the client proxy now includes the begin and end methods for both the service contract operations, because you can call them asynchronously (the synchronous version of each operation is also included in the proxy ). These changes are only implemented by the client proxy; the service actually does not pay attention to them. 3. Edit the program. CS file under the adventurewokrsadmintestclient project. Remove statements such as calling calculatetotalvalueofstock, console. writeline, and disabling proxy. Then add the following code: the above Code calls the client's asynchronous version calculatetotalvalueofstock method three times. The result will be processed in a method named calculatetotalvalueofstockcallback, which will be added in the next step. The proxy object is passed into the calculatetotalvalueofstockcallback method as the status parameter. It is very important to remove the proxy. Close method. If you disable the proxy at this time, the client's channel stack will be destroyed before the asynchronous call is completed during the WCF runtime, then the client program will not be able to obtain the corresponding service. 4. Add the callback method of the client. This method is a callback method. When the calculatetotalvalueofstock operation is completed, the agent will execute this method. It gets an object from the service return (this object is a status object, and it is a reference of proxy, this reference is used to pass in the begincalculatetotalvalueofstock method as the third parameter when the client program calls the begincalculatetotalvalueofstock method. This callback method also uses this object to call the endcalculatetotalvalueofstock method. The Return Value of the end method is the total inventory value calculated by the Service. 5. Run the solution in non-adaptive mode. The client starts and immediately displays "press enter to finish ". This is because calling the begincalculatetotalvalueofstock method will no longer block client programs. Do not press Enter now; allow the client to continue execution. After 20 or 30 seconds, you will see the message prompt box in the previous exercise. The message prompt box indicates whether the service executes each request synchronously or asynchronously. After all the operations are completed, the calculation result is displayed in the console window of the client program. 6. When all results are displayed, press enter to close the console window of the client program. From these exercises, you should have understood the differences between asynchronous call operations on the client and the support for asynchronous operations in the overall service implementation. Developers can decide whether to use a pair of methods to implement an operation to implement the iasyncresult design mode, independent of any client program. These methods appear in the client using a single method, and their implementation is completely transparent. Similarly, when creating a WCF client program and developers want to call asynchronous operations, they only need to produce an asynchronous proxy (or use the add service reference wizard, or use the svcutil tool to add the/async parameter ). Whether the client program synchronously calls the operation is transparent to the service. Finally, you should realize that even though the client program can call the service operation remotely, the service can still use the synchronous method to implement the operation, and vice versa. The implementation of the client and the service is quite flexible. Furthermore, you can define both the synchronous version and the asynchronous version for service operations in the following ways. However, if you do this, both operations will appear in the same action described in the Service's WSDL. In this case, WCF will not throw an exception, and it will always use synchronous version operations compared to asynchronous version operations (because WCF assumes that synchronous operation versions can get output more quickly ). Therefore, do not define both synchronous and asynchronous versions for the same operation in the same service.

 

One-way operations are especially suitable for scenarios where "Trigger and forget", in which the client program does not expect the service to return any information. However, many operations do not apply to this situation and return data to the client program. To handle these situations, WCF supports asynchronous operations and the iasyncresult design mode. In WCF, You can implement the iasyncresult design mode in two ways: asynchronously calling operations in the client program; or implementing asynchronous operations in the WCF Service. The iasyncresult design mode is not specifically designed for WCF. It is widely used in. NET Framework. For more details, refer to the "asynchronous programming design mode" of msdn. When using the svcutil command line tool, specify the "/aysnc" flag to generate a specific version of the proxy class. You can also click the Advanced button in the add service reference wizard, and then select the generate Asynchronous Operation check box in the service reference Settings dialog box to generate a proxy class of this specific version. An asynchronous proxy class provides a pair of begin and end methods for each operation. . The client can call the begin method to instantiate the operation. The begin method understands the returned results after sending the request. However, when the. NET Framework is running, a new thread is created on the client to wait for the response of the request. When you call the begin method, you need to provide the name of the callback method. After the service completes the operation and returns the result only as a client proxy, the callback method in the new thread starts to be executed. You can use the callback method to obtain the returned results of the service. You should call the end method of the operation to indicate that you have processed the service response. Understanding this is important later: to support the above asynchronous programming, you do not need to modify the service in any way. In fact, the service itself does not need to be a WCF Service; it may be a service implemented by other technologies. The code for asynchronous operations on the client program is encapsulated in the agent object of the client and the. NET Framework runtime. All thread-related problems are handled by the code running in the client's WCF runtime. The Service focuses on the same operations as the exercises in the previous section. Implement Asynchronous operations in the WCF Service using WCF. You can also implement asynchronous operations in the service. In this case, the service provides its own begin and end methods to form this operation . The client uses a common operation name to call an operation through a proxy object (the begin method is not used ). Therefore, the client does not have to worry about whether the Service implements this operation asynchronously. Service developers can add the logic to the begin method to select operations that should be performed synchronously or asynchronously by the local user. For example, if the current load of the service is relatively small, you can perform the operation synchronously so that the operation can be completed as soon as possible. If the load increases, the Service may choose to perform operations asynchronously. In this way, you do not need to modify the client program. If the operation returns data to the client after a long time, you should use this method to perform these operations. When defining an operation of a service, set the aysncpattern attribute of the operationcontract feature class to true to specify that the Operation supports asynchronous processing; then, we provide a pair of methods that follow the name conversion and signature described above to implement the iasyncresult design mode. In the following group of exercises, you will add another operation named calculatetotalvalueofstock to the adventureworksadmin service. The purpose of this operation is to determine the current total value of all inventories in the adventureworks warehouse. This operation takes some time to complete. Therefore, you need to use an Asynchronous Method to implement this operation. Exercise: add an asynchronous operation to the adventureworksadmin service. 1. Open the iservice. CS file in the app_code folder in Visual Studio. Add the following operation to the service contract adventureworksadmin. This operation contains two methods: begincalculatetotalvalueofstock and endcalculatetotalvalueofstock. Together, they form a single asynchronous operation called calculatetotalvalueofstock. In this operation, you must use the above naming method to name these two methods. Only in this way can client proxy objects correctly recognize them. You can specify any parameters required for this begin method (in this example, the client program will pass a string parameter to identify the call of the operation ), however, the last two parameters of this method must be an aysnccallback object. This object points to a callback method in the client program, and the other parameter is an object, it holds the State Information provided by the client program. The Return Value of the begin method must be iasyncresult. The end method must receive a single parameter of the iasyncresult type, but its return value should correspond to the return value of the operation. In this example, the calculatetotalvalueofstock operation returns an int type and its value is the calculation result of the total inventory value. Another important part of this operation is the asyncpattern attribute of the operationcontract feature class. You only need to apply the operationcontract feature to the begin method. When you generate the metadata of the service (such as generating a client proxy), this attribute will lead to the implementation of the begin and end as a single asynchronous operation. 2. In the solution window, right-click the app_code folder and select Add saved project. Add the ayncresult. CS file in the Directory D: \ works \ solutions \ WCF \ step. By. Step \ chapter12. 3. Open the aysncresult. CS file and check its content. It contains a generic class named asyncresult, which implements the iasyncresult interface. This class is more detailed than the returned results of this book, but the purpose of the aysncresult class is to provide synchronous methods and status information for other classes that Implement Asynchronous methods. In this exercise, two important members of this class are:
    • The data attribute can read the data returned by an asynchronous operation. In this column, the calculatetotalvalueofstock operation fills in this attribute and returns asyncresult to the client program when the end method is executed.
    • The aysncresult constructor receives two parameters and stores them in the corresponding two private variables. The Service will use the synchronous parameter to specify whether to call the operation synchronously. The statedata parameter will point to the last parameter object passed in the begin method (it is very important to save this object, because the object must return the client program to ensure that the object has been processed)
4. Open the service. CS file in the app_code folder. Then add the following proxy to the adventureworksadmin class. You will use this proxy in the method added later. 5. Add the following method to the adventureworksadmin class. The details of the above method work are beyond the scope of this book (strictly speaking, this method has nothing to do with WCF ). However, in general, this method generates a random number. If this number is an even number, it will execute operations in synchronous mode (simulating low-load scenarios ); otherwise, the operation is performed asynchronously (simulating high-load scenarios ). In the synchronization scenario, the code will create a new asyncresult object. The thread will sleep for 20 seconds to simulate the computing execution time, and then fill the aysncresult object with the number 55555555. In an asynchronous scenario, the Code also creates a new asyncresult object, but a new thread is generated, which slews for 30 seconds in the background. The Code does not fill in the asyncresult object, because when the background sleep thread wakes up, it will fill in the aysncresult object. In both cases, The code will call the callback method in the client program and pass the asyncresult object as the callback method parameter. . The client program receives the calculation result from this object. The callback method will return the same aysncresult object (which is required by the iasyncresult design mode ). This method also displays a message dialog box to help you track the execution of the method and determine whether the operation is synchronous or asynchronous. 6. Add the end method to the adventureworksadmin class. Call the above end method after the begin method is completed. The purpose of this method is to obtain the data attribute value from the passed iasyncresult object (this value is the calculation result of the operation ). If the operation is executed asynchronously, the operation may not be completed yet (the program that calls the in method of an asynchronous operation can call the end method at any time after the begin method ends, therefore, the end method must be completed before it returns ). In this example, the asyncresult object indicates that the method remains in the waiting state until the operation is completed. This method extracts data from asyncresult and returns the data only after the operation is complete. 7. Add the following method to the adventureworksadmin class. If the begin method decides to execute tasks asynchronously, The begin method creates a new thread in the background to simulate and execute the computation. The new thread will sleep for 30 seconds. When the background thread starts to sleep, register the endaysncsleep method as a callback method. 30 seconds later, the operating system activates the background thread and calls this method. This method fills in the Data Attribute of the aysncresult object and indicates that the operation has been completed. This will release the main thread of the service because the main thread is waiting for the end method. After the end method ends, the main thread of the service can return data to the client. Note that the return values of an operation are different, depending on whether the service performs a synchronous operation (returns 55555555) or an asynchronous operation (returns 999999 ). 8. Generate a solution. Exercise: Call calculatetotalvalueofstock In the WCF client. 1. In the adventurewokrsadmintestclient project, expand the service reference folder, right-click the adventureworksadmin service reference, and click Update Service reference. This operation will produce a new version of the client proxy, which includes the calculatetotalvalueofstock operation 2. In the solution browser window, make sure that the check boxes for displaying all files are selected. 3. Expand adventureworksadmin service reference, expand the reference. svcmap folder, and open the reference. CS file. Check the definitions of service contracts in the administrativeservice interface. Note that the new operation named calculatetotalvalueofstock is not marked as begin or end. In fact, this operation is implemented asynchronously and completely transparent to the client program. 4. Edit the program. CS file and delete the generatedailysalesreport and console. writeline statements in the try code snippet. Then add the following code to call the calculatetotalvalueofstock method three times and display the call result. If successful, at least one of these calls of the service is executed in a different way (either synchronous or asynchronous) from the other two ). 5. Running the solution in non-adaptive mode depends on the random number generated by the service. The random number determines whether the operation is performed synchronously or asynchronously. If you are not lucky, you must wait 20 seconds to see the first message prompt box: this is because the random number generated in the calculatetotalvalueofstock method generates an even number, and then the operation will be performed synchronously. The following message prompt box is displayed immediately after the message prompt box is displayed: After you click the confirm button, you will see result 55555555 displayed in the console window of the client program. If you only see the second message prompt box, begincalculatetotalvalueofstock has decided to execute the Asynchronous Method. After you close the message prompt box, you need to wait 30 seconds. You will see the following message prompt box: 999999 will also be displayed in the console window of the client program. Each method that the client program calls the calculatetotalvalueofstock operation repeats the above process. 6. Press enter in the console window of the client program to stop the client. So far, everything has been quite good. You have solved a lot of problems, so that you can allow the Service to determine the best strategy for long execution or resource-consuming creation. However, the client still uses the synchronization method so far. Every time the calculatetotalvalueofstock operation is called, it will be blocked until the operation is completed. Fortunately, you can use the svcutil tool to add/async parameters to generate a proxy that supports asynchronous client operations. This is what needs to be done in the following exercises. Exercise: Call calculatetotalvalueofstock asynchronously in the WCF client program. 1. In the adventurewokrsadmintestclient project, expand the service reference folder, right-click the adventureworksadmin service reference, and click Configure service reference. In the service reference Settings dialog box, select the generate Asynchronous Operation check box, and then click OK. 2. Check the reference. CS file in the reference. svcmap folder. You will see that the client proxy now includes the begin and end methods for both the service contract operations, because you can call them asynchronously (the synchronous version of each operation is also included in the proxy ). These changes are only implemented by the client proxy; the service actually does not pay attention to them. 3. Edit the program. CS file under the adventurewokrsadmintestclient project. Remove statements such as calling calculatetotalvalueofstock, console. writeline, and disabling proxy. Then add the following code: the above Code calls the client's asynchronous version calculatetotalvalueofstock method three times. The result will be processed in a method named calculatetotalvalueofstockcallback, which will be added in the next step. The proxy object is passed into the calculatetotalvalueofstockcallback method as the status parameter. It is very important to remove the proxy. Close method. If you disable the proxy at this time, the client's channel stack will be destroyed before the asynchronous call is completed during the WCF runtime, then the client program will not be able to obtain the corresponding service. 4. Add the callback method of the client. This method is a callback method. When the calculatetotalvalueofstock operation is completed, the agent will execute this method. It gets an object from the service return (this object is a status object, and it is a reference of proxy, this reference is used to pass in the begincalculatetotalvalueofstock method as the third parameter when the client program calls the begincalculatetotalvalueofstock method. This callback method also uses this object to call the endcalculatetotalvalueofstock method. The Return Value of the end method is the total inventory value calculated by the Service. 5. Run the solution in non-adaptive mode. The client starts and immediately displays "press enter to finish ". This is because calling the begincalculatetotalvalueofstock method will no longer block client programs. Do not press Enter now; allow the client to continue execution. After 20 or 30 seconds, you will see the message prompt box in the previous exercise. The message prompt box indicates whether the service executes each request synchronously or asynchronously. After all the operations are completed, the calculation result is displayed in the console window of the client program. 6. When all results are displayed, press enter to close the console window of the client program. From these exercises, you should have understood the differences between asynchronous call operations on the client and the support for asynchronous operations in the overall service implementation. Developers can decide whether to use a pair of methods to implement an operation to implement the iasyncresult design mode, independent of any client program. These methods appear in the client using a single method, and their implementation is completely transparent. Similarly, when creating a WCF client program and developers want to call asynchronous operations, they only need to produce an asynchronous proxy (or use the add service reference wizard, or use the svcutil tool to add the/async parameter ). Whether the client program synchronously calls the operation is transparent to the service. Finally, you should realize that even though the client program can call the service operation remotely, the service can still use the synchronous method to implement the operation, and vice versa. The implementation of the client and the service is quite flexible. Furthermore, you can define both the synchronous version and the asynchronous version for service operations in the following ways. However, if you do this, both operations will appear in the same action described in the Service's WSDL. In this case, WCF will not throw an exception, and it will always use synchronous version operations compared to asynchronous version operations (because WCF assumes that synchronous operation versions can get output more quickly ). Therefore, do not define both synchronous and asynchronous versions for the same operation in the same service.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.