S
Sudip_inn
Guest
this below way i develop a async routine where i used async & await keyword. some one told me to use ConfigureAwait(false).
i need to know what is ConfigureAwait(false) ?
and when to use ConfigureAwait(false) ?
so please come with a small example which show me the usage of ConfigureAwait(false). please post a sample code. thanks
private async void button1_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add("Section", typeof(string));
dt.Columns.Add("LineItem", typeof(string));
DataRow dr = dt.NewRow();
dr["Section"] = "Test1";
dr["LineItem"] = "Test2";
dt.Rows.Add(dr);
var task1 = GetData(dt);
await Task.WhenAll(task1);
List<BrokerData> _tmp = task1.Result;
}
private async Task<List<BrokerData>> GetData(DataTable Lidistinctdt)
{
List<BrokerData> Bogeylist = null;
await Task.Run(() =>
{
Bogeylist = Lidistinctdt.AsEnumerable()
.Select(row => new BrokerData
{
Section = (row.Field<string>(0)).ToString(),
LineItem = (row.Field<string>(1)).ToString()
}).ToList();
});
return Bogeylist;
}
public class BrokerData
{
public string Section { get; set; }
public string LineItem { get; set; }
}
Continue reading...
i need to know what is ConfigureAwait(false) ?
and when to use ConfigureAwait(false) ?
so please come with a small example which show me the usage of ConfigureAwait(false). please post a sample code. thanks
private async void button1_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add("Section", typeof(string));
dt.Columns.Add("LineItem", typeof(string));
DataRow dr = dt.NewRow();
dr["Section"] = "Test1";
dr["LineItem"] = "Test2";
dt.Rows.Add(dr);
var task1 = GetData(dt);
await Task.WhenAll(task1);
List<BrokerData> _tmp = task1.Result;
}
private async Task<List<BrokerData>> GetData(DataTable Lidistinctdt)
{
List<BrokerData> Bogeylist = null;
await Task.Run(() =>
{
Bogeylist = Lidistinctdt.AsEnumerable()
.Select(row => new BrokerData
{
Section = (row.Field<string>(0)).ToString(),
LineItem = (row.Field<string>(1)).ToString()
}).ToList();
});
return Bogeylist;
}
public class BrokerData
{
public string Section { get; set; }
public string LineItem { get; set; }
}
Continue reading...