Search code examples
asynchronouswindows-store-appssharepoint-2013windows

Error with Dispatcher.BeginInvoke


I am trying to add an item to a sharepoint list but when i try to save my changes im getting this error with my Dispatcher.BeginInvoke 'Windows.UI.Core.CoreDispatcher' does not contain a definition for 'BeginInvoke' and no extension method 'BeginInvoke' accepting a first argument of type 'Windows.UI.Core.CoreDispatcher' could be found (are you missing a using directive or an assembly reference?

 ctx.BeginSaveChanges(
  (IAsyncResult result) => Dispatcher.BeginInvoke(
      () => ctx.EndSaveChanges(result)),
   ctx

);


Solution

  • Should use the following instead:

    await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => {
    }