接受约会时app中的System.ArgumentException

时间:2016-07-13 15:28:49

标签: c# uwp appointment argumentexception

接受约会时,会在调用UWP C#/ XAML应用程序中抛出ArgumentException。取消预约似乎工作正常。

我已将受影响的代码修改为:

private async void Button_Click(object sender, RoutedEventArgs e)
{
    await Task.Run(() =>
    {
        DispatcherHelper.CheckBeginInvokeOnUI(async () =>
        {
            var appt = new Appointment();
            var rect = new Rect(new Point(Window.Current.Bounds.Width / 2, Window.Current.Bounds.Height / 2), new Size());
            string id = await AppointmentManager.ShowAddAppointmentAsync(appt, rect, Placement.Default);
            Debug.WriteLine(id);
        });
    });
}

/* ArgumentException
HResult=-2147024809
Message=Value does not fall within the expected range.
Source=mscorlib
StackTrace:
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at eovimcd_mobile_windows.MainPage.<>c.<<Button_Click>b__4_1>d.MoveNext()
*/

以下行触发启动日历应用,以便用户确认添加约会:

string id = await AppointmentManager.ShowAddAppointmentAsync(appt, rect, Placement.Default);

接受约会时,该行引发了ArgumentException,取消按预期恢复执行。

我知道在UI线程上删除Task和dispatch非常有效。该应用程序的构建方式是从嵌入式Web视图接收创建约会的触发器,然后执行任务运行,最后强制在UI线程上执行约会创建。

0 个答案:

没有答案