Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

XF for WinPhone8.1 (RT) Preview - BeginInvokeOnMainThread broken?

$
0
0

I ran into problems while trying to use BeginInvokeOnMainThread with the XF for Windows Preview on Windows Phone 8.1 (Runtime). I can duplicate the problem with a simple contrived example. I added the following code to the BasicListPage constructor in Xamarin's WorkingWithListview example:


            System.Threading.Tasks.Task.Run(async () =>
            {
                await System.Threading.Tasks.Task.Delay(5000);
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => DisplayAlert("Time's up", "", "OK"));
            });

On iOS, Android, and Windows Phone 8.0 Silverlight, the code works as expected: the alert box is displayed 5 seconds after the app starts up. On Windows Phone 8.1 RT, however, this exception is generated instead:


  System.NullReferenceException occurred
  _HResult=-2147467261
  _message=Object reference not set to an instance of an object.
  HResult=-2147467261
  IsTransient=false
  Message=Object reference not set to an instance of an object.
  Source=Xamarin.Forms.Platform.WinRT
  StackTrace:
       at Xamarin.Forms.Platform.WinRT.WindowsBasePlatformServices.BeginInvokeOnMainThread(Action action)
  InnerException: 

The call stack looks like this:


    Xamarin.Forms.Platform.WinRT.DLL!Xamarin.Forms.Platform.WinRT.WindowsBasePlatformServices.BeginInvokeOnMainThread(System.Action action = {System.Action})   Unknown
    Xamarin.Forms.Core.DLL!Xamarin.Forms.Device.BeginInvokeOnMainThread(System.Action action = {System.Action}) Unknown
>   WorkingWithListview.DLL!WorkingWithListview.BasicListPage..ctor() Line 24   C#
    [Resuming Async Method] 
    mscorlib.ni.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.InvokeMoveNext(object stateMachine)   Unknown
    mscorlib.ni.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)    Unknown
    mscorlib.ni.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)    Unknown
    mscorlib.ni.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.Run() Unknown
    mscorlib.ni.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.OutputAsyncCausalityEvents.AnonymousMethod__0()  Unknown
    mscorlib.ni.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.ContinuationWrapper.Invoke() Unknown
    mscorlib.ni.dll!System.Runtime.CompilerServices.TaskAwaiter.OutputWaitEtwEvents.AnonymousMethod__0()    Unknown
    mscorlib.ni.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.ContinuationWrapper.Invoke() Unknown
    mscorlib.ni.dll!System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(System.Action action, bool allowInlining, ref System.Threading.Tasks.Task currentTask = null)  Unknown
    mscorlib.ni.dll!System.Threading.Tasks.Task.FinishContinuations()   Unknown
    mscorlib.ni.dll!System.Threading.Tasks.Task.FinishStageThree()  Unknown
    mscorlib.ni.dll!System.Threading.Tasks.Task.TrySetResult(System.Threading.Tasks.VoidTaskResult result)   Unknown
    mscorlib.ni.dll!System.Threading.Tasks.Task.DelayPromise.Complete() Unknown
    mscorlib.ni.dll!System.Threading.Tasks.Task.Delay.AnonymousMethod__19(object state) Unknown
    mscorlib.ni.dll!System.Threading.TimerQueueTimer.CallCallbackInContext(object state)    Unknown
    mscorlib.ni.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)    Unknown
    mscorlib.ni.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)    Unknown
    mscorlib.ni.dll!System.Threading.TimerQueueTimer.CallCallback() Unknown
    mscorlib.ni.dll!System.Threading.TimerQueueTimer.Fire() Unknown
    mscorlib.ni.dll!System.Threading.TimerQueue.FireNextTimers()    Unknown
    mscorlib.ni.dll!System.Threading.TimerQueue.AppDomainTimerCallback()    Unknown

Is this a known issue with the preview? Do you have an ETA on when the next version will be available? We are generally finding the WinRT preview to be very useful, since it opens up a lot more options for us.


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>