How the Deployment.Current.Dispatcher.BeginInvoke work in windows store app?
c#, microsoft-metro, windows-phone-7, windows-phone-8, windows-store-apps
Solution
Have you tried using this instead of the Deployment.Current.Dispatcher.BeginInvoke
CoreDispatcher dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
});
EDIT:
The whole method then being:
private async void OnChangesSaved(IAsyncResult result)
{
bool errorFound = false;
CoreDispatcher dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
this._context = result.AsyncState as THA001_devEntities;
try
{
// Complete the save changes operation.
this._context.EndSaveChanges(result);
}
catch (DataServiceRequestException ex)
{
errorFound = true;
MessageBox.Show("Error, While Updating Record");
}
if (!errorFound)
{
MessageBox.Show("Record Successfully Updated");
}
});
}
Problem
i got experience with windows phone 8 and i am using WCF data services, i am able to update my record successfully with following code : ``` public void UpdateJob1(EquipBooking equipBooking) { this._context.UpdateObject(equipBooking); this._context.BeginSaveChanges(OnChangesSaved, this._context); } private void OnChangesSaved(IAsyncResult result) { bool errorFound = false; Deployment.Current.Dispatcher.BeginInvoke(() => { this._context = result.AsyncState as THA001_devEntities; try { // Complete the save changes operation. this._context.EndSaveChanges(result); } catch (DataServiceRequestException ex) { errorFound = true; MessageBox.Show("Error, While Updating Record"); } if (!errorFound) { MessageBox.Show("Record Successfully Updated"); } } ); } ``` but i got problem while write same code in window store app, i am not able to update record , i got problem here : `Deployment.Current.Dispatcher.BeginInvoke` can anyone guide me, or rewrite my code? thanks