I am getting Error:
Cannot implicitly convert type 'System.Data.DataTable' to 'System.Threading.Tasks.Task'
The GetExternalMessage is taking Time to execute and hence the WinForm Stops responsing. Hence I thought of appling "Task Await". But still i am getting error. How can we return a dataTable in Task?
Below is the code I am trying:
private void button1_Click(object sender, EventArgs e)
{
dtFrom.Format = DateTimePickerFormat.Short;
dtTo.Format = DateTimePickerFormat.Short;
DataTable dt = new DataTable();
//dt = GetExtMsg(dtFrom.Text, dtTo.Text);
}
async Task<DataTable> GetExtMsg(string dateFrom, string dateTo)
{
DL dl = new DL();
DataTable dt = new DataTable();
dt = dl.GetExternalMessage(dateFrom, dateTo);
Task<DataTable> tastDT = dt;
}