In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "how to use ASP.NET/WebService". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Sqlconnection () {} creates the Connection in this way, because ASP.NET/WebService automatically executes the Connection.dispose () method when it exceeds {}, so you can ensure that Connetion is closed in a timely manner. 1) is it really so important to call .dispose () in time? if an object exceeds the living space, won't it be automatically cleaned up by the GC (garbage collector) in .net?
This problem is actually caused by GC, the GC used in. Net, he is not as diligent in his work as we are. GC only cleans up (cleaning up unused objects) when the external environment is very bad (when there is not enough content to distribute). So for Connection, even if it is beyond the lifetime of the variable, it may not have been killed by GC. ASP.NET/WebService is still not returned to Connection Pool.
So this leads to the possibility that the next connection may have a Connection without Available in Connection Pool and reopen a new connection, wasting extra performance for no reason. So ASP.NET/WebService repeatedly stressed the need to close the current connection in a timely manner. One * * method is to use using {} block system to automatically call the connection.dispose method when exiting {}, while dispose will automatically execute the close method to release the current connection. In fact, the ASP.NET/WebService method is to call the close method once, so the two methods are identical. That is, if you execute the connection.close () method in time, there is no need to wrap the connection in a using () {}.
3) if using using is necessary, what if the program structure makes it impossible for me to use using () {} to wrap my Connection, for example, my Connection is the same help class return place?
This is a common problem. In such an environment, we can't wrap the entire ASP.NET/WebService in one connection. There are two ways to solve this problem. One is to modify your code structure. Pass in a ConnectionString to return Connection. Another way is to double-check your code to see if Connection is closed in time. Because the effect of Close is the same as dispose. Of course, if we do not use using () {}, the task of shutting down Connection in time, it will be in our own hands, instead of being guarded by. Net framework.
If your project is ASP.NET/WebService, we recommend that you use Connection Pool because this feature can help you reduce the huge system overhead caused by frequent connection creation. If your system is a Cmax S model structure, we do not recommend you to use Connection Pool, because generally speaking, in such a model, each user uses their own user name and password to connect to the background database, using a different Connection String, so there is no frequent problem of opening / closing database connections, in fact, in the Cmax S model.
You can always keep a Connection maintenance open off instead of Close, which can improve your system performance without consuming system resources due to the extra check of Connection Pool. Accordingly, you don't have to worry that the Connection that has been open for a long time occupies the connection, resulting in other connections cannot be obtained from the connection pool in time. (because you don't need to use connection pool at all).
That's all for the content of "how to use ASP.NET/WebService". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.