I have the following method
public List<VatRate> GetAll( string cnString )
{
List<VatRate> result = new List<VatRate>();
using (SqlConnection cn = new SqlConnection(cnString))
{
SqlCommand cmd = new SqlCommand();
cmd.Connection = cn;
cmd.CommandText = SQL_SELECT;
cmd.CommandType = System.Data.CommandType.Text;
cn.Open();
SqlDataReader reader = cmd.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
VatRate vr = new VatRate();
vr.IDVatRate = reader["IDVatRate"] == System.DBNull.Value ? Guid.Empty : (Guid)reader["IDVatRate"];
vr.Percent = reader["Percent"].XxNullDecimal();
vr.Type = reader["Type"].XxNullString();
vr.VatRateDescription = reader["VatRateDescription"].XxNullString();
}
}
reader.Close();
cn.Close();
}
return result;
}
It will be used in a WPF application, and I want to be able to inform the UI of the reading progress. Do I have to raise a simple event? something like OnProgress(new MyProgressEventHandler(recordcounter)); I know for certain that a method like this will freeze the UI while executing, is there something better that can be done for example using the asyncronous methods to still wait for the method execution but be able to inform the user of what it is doing?