I am using a query to fill a blankbox in the WPF application. I have a pop, but all the items are immediately closed before loading in the box. There is no way to control this. I have a passive busy indicator inside the Runawalkar compartment method, but it appears that it has been done before. Here's what I have:
private void before looking link (object sender, routing avent ARG e) {CboCustomerList.Items.Clear (); Busy indicator Isubcussi = true; BackgroundWorld SearchWorker = new backgroundwork (); ItemSearchWorker.DoWork + = New DoWorkEventHandler (FillCustomers); ItemSearchWorker.RunWorkerCompleted + = New RunWorker Component Action Handler (itemSearchWorker_Completed); ItemSearchWorker.RunWorkerAsync (); } Private void before SearchWorker_Completed (object sender, RunWorkerCompletedEventArgs e) {//busyIndicator.Visibility = System.Windows.Visibility.Hidden; Busy indicator ISUB = false; } Private Zero FillCustomers (Object Sender, DoWorkEventArgs E) {SqlDataAdapter Adapter = New SqlDataAdapter (); Dataset ds = new dataset (); String sql = "Siititibl to Choosing NAME of orders; String Connection String = settings. Difoltkprodkshn connection; SqlConnection connection = new SqlConnection (connectionString); SqlCommand SqlCmd = new SqlCommand (); SqlCmd.CommandType = CommandType.Text; SqlCmd .Connection = connection; SqlCmd.CommandText = sql; SqlDataReader reader = null; connection.Open (); reader = SqlCmd.ExecuteReader (); list & lt; string & gt; ListOfString = new list & lt; string & gt; (); while (ReaderkRead ()) {ListOfStringkAdd (reader [ "NAME"]. ToString ());} Dispatcher.Invoke ((action) (() = & gt; CboCustomerList.ItemsSource = listOfString)) ; Connection.Close ();} < / Code>
Note the settings of the indicator before calling, and to close the busy indicator in the item SearchWorker_Completed function, until the entire function is not asked before, should not wait? < According to MSDN, you should never manipulate the UI object in the background worker dwarf event.
No comments:
Post a Comment