Synchronous and asynchronous WCF (with WPF connectivity as an example)

Source: Internet
Author: User

2016-06-0711:05:44

When you learn WCF, you learn the synchronization and asynchrony of WCF services.

I understand that synchronization is:

When a WCF service is executed synchronously, the program has only one thread, and the code can only be executed sequentially, and when the client/server execution takes 10 seconds, it can only wait 10 seconds before executing the code.

When a WCF service is executed asynchronously, the program can run concurrently with multiple threads, and when a client/server method executes for 10 seconds, the subsequent code is also performing the operation.

1. First build a WCF service and WPF project, WPF Project Reference WCF service, configure WCF Service reference for WPF project

2. Server-side interface: Itable1service

3. Service-side interface implementation: Table1service

4. Client calls. Note: Import the server-side namespace and the WCF service namespace.

4.1 Implementing WCF Service synchronization

Click the test WCF Service button, and the WCF service executes the results synchronously. ("WCF End" executes after "WCF service synchronization" is executed after the thread has been interrupted for 10 seconds.) Note the current time at which the execution is observed. )

4.2 Implementing WCF Services asynchronously

Click the test WCF Service button, and the WCF service executes the result asynchronously. WCF async and WCF end are executed at the same time, and WCF end does not wait for the "WCF Async" execution to break after 10 seconds to execute.

The record is complete.

Synchronous and asynchronous WCF (with WPF connectivity as an example)

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.