Synchronous and asynchronous WCF (using WPF connection as an example), wcfwpf

Source: Internet
Author: User

Synchronous and asynchronous WCF (using WPF connection as an example), wcfwpf

2016 to 06-0711: 05: 44

When learning about WCF, I learned how to synchronize and asynchronously use the WCF Service.

I understand synchronization as follows:

When the WCF Service is executed synchronously, the program has only one thread, and the code can only be executed step by step in sequence. When the execution of a Client/Server method takes 10 seconds, the code can only be executed after 10 seconds.

When the WCF Service is executed asynchronously, the program can run multiple threads simultaneously. When the client/server executes a method for 10 seconds, the subsequent code is also executed.

1. Create a WCF Service and WPF project. The WPF project references the WCF Service and configure the reference of the WCF Service of the WPF project.

2. Server Interface: ITable1Service

3. Implementation of the server interface: Table1Service

4. Client call. Note: import the server namespace and the WCF Service namespace.

4.1 implement WCF Service Synchronization

Click the "test WCF Service" button to synchronize the execution results of the WCF Service. (The "WCF ended" execution is executed 10 seconds after the "WCF Service synchronization" is executed and the thread is interrupted. Observe the current execution time .)

4.2 asynchronous Implementation of the WCF Service

Click the "test WCF Service" button to asynchronously execute the result of the WCF Service. "WCF Asynchronization" and "WCF termination" are executed at the same time. "WCF termination" does not wait 10 seconds until the "WCF Asynchronization" is executed and then interrupted.

 

Record completed.

 

Related Article

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.