Firstly, you cannot use async/ awaitwith .NET 4 or C # 4. This is a new feature in C # 5. There were CTPs that were installed on top of .NET 4, but there are certain errors in these CTPs - do not use them. You should use the full version of .NET 4.5, which includes the C # 5 compiler. (All this in Visual Studio 2012.)
-, , . Result - , Task<T>.
-, Result , , . :
public DataTable GetData(string sql, string connectionName)
{
DataTable dt = (DataTable)GetDataAsync(sql, connectionName).Result;
return dt;
}
... :
public DataTable GetData(string sql, string connectionName)
{
return FillData(sql, connectionName);
}
, .