Optimization suggestions for using. Net to develop Windows form network applications provided by Microsoft msdn

Source: Internet
Author: User


This article focuses on the use of Microsoft's DOTNET platform for network-related winformProgramDevelopment.

In the. NET platform, network-related content is basically included in the namespace system. net.


On msdn, Microsoft provides the following optimization suggestions:


Use as much as possibleWebrequestAndWebresponseInstead of converting the data typeChild class. Applications that use webrequest and webresponse can use the new Internet protocol without a wide range of code changes, facilitating smooth upgrade.


When using the system. Net class to write ASP. NET applications running on the serverGetresponseAndGetresponsestreamThe Asynchronous Method is usually better. This article also applies to the Development of Windows programs. In order to avoid Main UI blocking and improve ue, asynchronous mode is also a better choice.


The number of connections opened for Internet resources may significantly affect network performance and throughput. By default, system. net uses two connections for each application on each host. Set the connectionlimit attribute in the servicepoint of the application to add this number to a specific host. Set servicepointmanager. defaultpersistentconnectionlimit to add this default value to all hosts.


When writing socket-level protocols, try to use tcpclient or udpclient instead of writing directly to the socket. These two client classes encapsulate the creation of TCP and UDP sockets without the need to process the connection details.


When accessing the site or application that requires creden。, use the credentialcache class to create a credential cache instead of providing them for each request. The credentialcache class searches for cache to find the appropriate creden。 to be provided to the request, so that you do not have to create and provide creden。 Based on the URL.


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.