TAILIEUCHUNG - Filling a DataSet Asynchronously

[ Team LiB ] Recipe Filling a DataSet Asynchronously Problem Given some database queries that return large result sets and cause the calling application to be unresponsive, you need to make the application more responsive during the fill. | Team LiB Recipe Filling a DataSet Asynchronously Problem Given some database queries that return large result sets and cause the calling application to be unresponsive you need to make the application more responsive during the fill. Solution Create a background thread and use it to run a query to fill a DataSet. You can also fill a DataGrid object from a background thread. The sample code contains one event handler and two methods Go Checks whether there is an existing background thread loading the DataSet. If the DataSet is not being loaded a new thread is created invoking the AsyncFillDataSet method to fill a DataSet. Otherwise a message is displayed stating that the DataSet is currently being filled. AsyncFillDataSet This method loads a DataSet with the Orders and Order Details tables from the Northwind database. The BindDataSetToDataGrid method is called asynchronously on the form s thread to display the results. Finally messages are displayed to indicate that the AsyncFillDataSet method has started and when it has completed. BindDataSetToDataGrid This method binds the default view of the Orders table in the DataSet to the data grid on the form. The C code is shown in Example 9-1. Example 9-1. File Namespaces variables and constants using System using using using using using private delegate void BindDataSetToDataGridDelegate DataSet ds Table name constants private const String ORDERS_TABLE Orders private const String ORDERDETAILS_TABLE OrderDetails Relation name constants private const String ORDERS_ORDERDETAILS_RELATION Orders_OrderDetails_Relation Field name constants private const String ORDERID_FIELD OrderlD private const String ORDERDATE_FIELD OrderDate private bool isWorking false . . . private delegate void BindDataSetToDataGridDelegate DataSet ds private void goButton_Click object sender e

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.