我的进度条有问题,因为它在加载数据之前没有显示。
我不确定我的代码是对还是错。请帮助解决这个问题及其让我头疼的问题。任何建议都会对我非常有帮助plzzz ..
progressBar1.Minimum = 0;
progressBar1.Maximum = short.MaxValue;
progressBar1.Value = 0;
double value = 0;
UpdateProgressBarDelegate updatePbDelegate = new UpdateProgressBarDelegate(progressBar1.SetValue);
foreach (CDType ctp in dgAttributes.ItemsSource)
{
if (ctp.IsSelected == true)
{
//Mouse.OverrideCursor = Cursors.Wait;
var CDTypeID = ctp.TYPE_ID;
label3.Content = "Loading.." + CDTypeID;
SqlCommand sqlCommand = new SqlCommand(conn.ConnectionString);
sqlCommand.CommandType = CommandType.StoredProcedure;
sqlCommand.CommandText = "LOAD_DATA_SOURCE_SAVE";
sqlCommand.Parameters.AddWithValue("CDTYPE_ID", CDTypeID);
sqlConnection.Open();
sqlCommand.Connection = sqlConnection;
do
{
value += 1;
Dispatcher.Invoke(updatePbDelegate,
System.Windows.Threading.DispatcherPriority.Background,
new object[] { ProgressBar.ValueProperty, value });
//i'm not sure whether its correct way or not to give below line here..? I mean execute non query...since it was looping all the time untill its reaches Maximum value
//sqlCommand.ExecuteNonQuery();
}
while (progressBar1.Value != progressBar1.Maximum);
sqlConnection.Close();
//label3.Content = "Sucessfully Loaded..!";
}
}