Besides providing storage, the application object also raises several  dịch - Besides providing storage, the application object also raises several  Việt làm thế nào để nói

Besides providing storage, the appl

Besides providing storage, the application object also raises several events that you can use to run code at various points in the life of an application, such as when it starts, when it ends, or when an error occurs. One of the uses of these events is to initialize the values of application state items, as shown in figure 8-8. To work with these events, you first add a Global.asax file to the project as described in this figure.
By default, this file contains method declarations for five event handlers as shown in the example in this figure. Then, you can add code to any of these event handlers. This figure summarizes the four events you’re most likely to use.
The example in this figure shows how you can initialize and update a session state item named HitCount that keeps track of the number of times a new session is started for an application. In this example, the Application_Start event handler retrieves the current hit count number from a database and adds an application state item named HitCount to the application state object. Similarly, the Application_End event handler saves the HitCount item to the database so it will be accurate when it’s retrieved the next time the application starts. Although the HalloweenDB class that includes the methods that are used to retrieve and update the count isn’t shown here, all you need to know is that the GetHitCount method retrieves the current hit count from the database as an integer value, and the UpdateHitCount method saves the integer value to the database.
The updating of the HitCount item takes place in the Session_Start event handler, which is raised whenever a new user session begins. Note that the code that updates the HitCount item uses the Lock and Unlock methods of the Application object.
When you’re working with application state data, you’ll want to lock the application state collection when you modify any of its data. To minimize the length of time the application state object is locked, you should do as little processing as possible between the Lock and Unlock methods.
If you don’t lock the application state collection while the count is updated, two or more users could access the count at the same time. To illustrate why that’s a problem, let’s assume that three users access the count item at the same time when its value is 11. Then, when each of those users increment the count it becomes 12, and that’s the value that each user stores in the application state collection. In this case, though, the correct count should be 14
0/5000
Từ: -
Sang: -
Kết quả (Việt) 1: [Sao chép]
Sao chép!
Besides providing storage, the application object also raises several events that you can use to run code at various points in the life of an application, such as when it starts, when it ends, or when an error occurs. One of the uses of these events is to initialize the values of application state items, as shown in figure 8-8. To work with these events, you first add a Global.asax file to the project as described in this figure.By default, this file contains method declarations for five event handlers as shown in the example in this figure. Then, you can add code to any of these event handlers. This figure summarizes the four events you’re most likely to use.The example in this figure shows how you can initialize and update a session state item named HitCount that keeps track of the number of times a new session is started for an application. In this example, the Application_Start event handler retrieves the current hit count number from a database and adds an application state item named HitCount to the application state object. Similarly, the Application_End event handler saves the HitCount item to the database so it will be accurate when it’s retrieved the next time the application starts. Although the HalloweenDB class that includes the methods that are used to retrieve and update the count isn’t shown here, all you need to know is that the GetHitCount method retrieves the current hit count from the database as an integer value, and the UpdateHitCount method saves the integer value to the database.The updating of the HitCount item takes place in the Session_Start event handler, which is raised whenever a new user session begins. Note that the code that updates the HitCount item uses the Lock and Unlock methods of the Application object.
When you’re working with application state data, you’ll want to lock the application state collection when you modify any of its data. To minimize the length of time the application state object is locked, you should do as little processing as possible between the Lock and Unlock methods.
If you don’t lock the application state collection while the count is updated, two or more users could access the count at the same time. To illustrate why that’s a problem, let’s assume that three users access the count item at the same time when its value is 11. Then, when each of those users increment the count it becomes 12, and that’s the value that each user stores in the application state collection. In this case, though, the correct count should be 14
đang được dịch, vui lòng đợi..
Kết quả (Việt) 2:[Sao chép]
Sao chép!
Ngoài việc cung cấp lưu trữ, đối tượng áp dụng cũng đặt ra một số sự kiện mà bạn có thể sử dụng để chạy mã tại các điểm khác nhau trong cuộc đời của một ứng dụng, chẳng hạn như khi nó bắt đầu, khi nó kết thúc, hoặc khi một lỗi xảy ra. Một trong những ứng dụng của những sự kiện này là để khởi tạo các giá trị của các mặt hàng nhà nước áp dụng, như thể hiện trong hình 8-8. Để làm việc với những sự kiện này, đầu tiên bạn thêm một tập tin Global.asax để các dự án như được mô tả trong hình này.
Theo mặc định, file này chứa các khai báo phương thức xử lý sự kiện trong năm như trong các ví dụ trong hình này. Sau đó, bạn có thể thêm mã vào bất kỳ của các xử lý sự kiện. Con số này tóm tắt trong bốn sự kiện mà bạn đang có nhiều khả năng để sử dụng.
Ví dụ trong hình này cho thấy làm thế nào bạn có thể khởi tạo và cập nhật một mục trạng thái phiên có tên HitCount mà theo dõi số lần một phiên mới được bắt đầu với một ứng dụng. Trong ví dụ này, xử lý sự kiện Application_Start lấy số lượng hit count hiện từ một cơ sở dữ liệu và thêm một mục nhà nước ứng dụng có tên HitCount để các đối tượng nhà nước ứng dụng. Tương tự như vậy, xử lý sự kiện Application_End lưu các mục HitCount cơ sở dữ liệu vì vậy nó sẽ được chính xác khi nó được lấy ra trong thời gian tới ứng dụng bắt đầu. Mặc dù lớp HalloweenDB bao gồm các phương pháp được sử dụng để truy xuất và cập nhật các số không được hiển thị ở đây, tất cả các bạn cần phải biết là các phương pháp GetHitCount lấy số hit hiện nay từ các cơ sở dữ liệu như là một giá trị số nguyên, và các phương pháp UpdateHitCount lưu các giá trị số nguyên với cơ sở dữ liệu.
Việc cập nhật các mục HitCount diễn ra trong xử lý sự kiện session_start, mà được nâng lên bất cứ khi nào một phiên người dùng mới bắt đầu. Lưu ý rằng mã đó cập nhật các mục HitCount sử dụng các Khóa và mở khóa các phương thức của đối tượng Application.
Khi bạn đang làm việc với các dữ liệu nhà nước ứng dụng, bạn sẽ muốn khóa các bộ sưu tập nhà nước áp dụng khi bạn sửa đổi bất kỳ dữ liệu của nó. Để giảm thiểu độ dài của thời gian đối tượng trạng thái ứng dụng bị khóa, bạn nên làm càng ít chế biến càng tốt giữa các Khóa và mở khóa các phương pháp.
Nếu bạn không khóa thu nhà nước ứng dụng trong khi đếm được cập nhật, hai hoặc nhiều người dùng có thể truy cập tính cùng một lúc. Để minh họa cho lý do tại sao đó là một vấn đề, ​​chúng ta hãy giả định rằng ba người dùng truy cập vào mục số cùng một lúc khi giá trị của nó là 11. Sau đó, khi mỗi người trong những người sử dụng tăng tính nó sẽ trở thành 12, và đó là những giá trị mà mỗi cửa hàng sử dụng trong Bộ sưu tập nhà nước ứng dụng. Trong trường hợp này, mặc dù, số lượng chính xác nên được 14
đang được dịch, vui lòng đợi..
 
Các ngôn ngữ khác
Hỗ trợ công cụ dịch thuật: Albania, Amharic, Anh, Armenia, Azerbaijan, Ba Lan, Ba Tư, Bantu, Basque, Belarus, Bengal, Bosnia, Bulgaria, Bồ Đào Nha, Catalan, Cebuano, Chichewa, Corsi, Creole (Haiti), Croatia, Do Thái, Estonia, Filipino, Frisia, Gael Scotland, Galicia, George, Gujarat, Hausa, Hawaii, Hindi, Hmong, Hungary, Hy Lạp, Hà Lan, Hà Lan (Nam Phi), Hàn, Iceland, Igbo, Ireland, Java, Kannada, Kazakh, Khmer, Kinyarwanda, Klingon, Kurd, Kyrgyz, Latinh, Latvia, Litva, Luxembourg, Lào, Macedonia, Malagasy, Malayalam, Malta, Maori, Marathi, Myanmar, Mã Lai, Mông Cổ, Na Uy, Nepal, Nga, Nhật, Odia (Oriya), Pashto, Pháp, Phát hiện ngôn ngữ, Phần Lan, Punjab, Quốc tế ngữ, Rumani, Samoa, Serbia, Sesotho, Shona, Sindhi, Sinhala, Slovak, Slovenia, Somali, Sunda, Swahili, Séc, Tajik, Tamil, Tatar, Telugu, Thái, Thổ Nhĩ Kỳ, Thụy Điển, Tiếng Indonesia, Tiếng Ý, Trung, Trung (Phồn thể), Turkmen, Tây Ban Nha, Ukraina, Urdu, Uyghur, Uzbek, Việt, Xứ Wales, Yiddish, Yoruba, Zulu, Đan Mạch, Đức, Ả Rập, dịch ngôn ngữ.

Copyright ©2024 I Love Translation. All reserved.

E-mail: