I have recently been trying to learn the process of using Task in WPF and have ran into a snag which more than likely is due to my lack of experience. When executing an asychronous call to my dataservice method "GetFutureWork" the UI thread becomes unresponsive. The code can be seen below. Note this project uses MVVM and the Variable "WorkList" is simply an observable collection used for my listiview's itemsource.
private async void LoadWork()
{
WorkList = await _dataService.GetFutureWork("UserNameHere");
}
DataService Task
public async Task<IEnumerable<FutureWork>> GetFutureWork(string userName)
{
using (_db = new DataEntities())
{
var workList = await (from items in _db.REPAIR_CHECK_IN_TABLEs
where items.LOCATION == userName && items.COMPLETED == "N"
select new FutureWork
{
FormattedDate = items.EstShipDate.ToString(),
ServiceID = items.SERVICE_ID,
ImagePath = @"\\192.168.5.50\photos$\" + items.SERVICE_ID + "P1.bmp",
Priority = items.PRIORITY
}).ToListAsync();
return workList;
}
}