private void ParameterizedThread(object obj) { System.Threading.Thread.Sleep(500); Int32 rowIndex = 0; ThreadParams threadParams = (ThreadParams)obj; FormProgress.delCloseForm deCloseForm = threadParams.FormProgress.CloseForm; FormProgress.delSetBodyText deSetBodyText = threadParams.FormProgress.SetBodyText; FormProgress.delSetProgressMaximum deSetProgressMaximum = threadParams.FormProgress.SetProgressMaximum; FormProgress.delSetProgressPosition deSetProgressPosition = threadParams.FormProgress.SetProgressPosition; //threadParams.FormProgress.Invoke(deSetBodyText, "Waiting on network..."); SqlDataSourceEnumerator instance = SqlDataSourceEnumerator.Instance; System.Data.DataTable table = instance.GetDataSources(); threadParams.FormProgress.Invoke(deSetBodyText, "Populating " + table.Rows.Count + " servers..."); threadParams.FormProgress.Invoke(deSetProgressMaximum, table.Rows.Count); foreach (System.Data.DataRow row in table.Rows) { SQLServerListObject sqlObject = new SQLServerListObject(row["ServerName"].ToString(), row["InstanceName"].ToString(), row["Version"].ToString(), CBool(row["isClustered"])); threadParams.OwnerForm.Invoke(threadParams.AddSQLServerToComboBox, sqlObject); threadParams.FormProgress.Invoke(deSetProgressPosition, rowIndex++); System.Threading.Thread.Sleep(10); } threadParams.FormProgress.Invoke(deCloseForm); }
private void AddSQLServerToComboBox(SQLServerListObject sqlObject) { cboServerName.Items.Add(sqlObject); }