【问题标题】:What is the Prism equivalent of DispatcherHelper?DispatcherHelper 的 Prism 等价物是什么?
【发布时间】:2019-08-06 19:26:27
【问题描述】:

我正在将代码库从 MVVMLight 重写为 Prism。我有一个 IDispatchOnUIThread 接口,我正在 iOS 中实现。

什么是 Prism 中 MVVMLight 的 DispatchHelper 等价物?

using MyApp.Model;
using GalaSoft.MvvmLight.Threading;
using System;

namespace MyApp.iOS
{
    public class DispatchOnUIThread : IDispatchOnUIThread
    {
        public void Invoke(Action action)
        {
            DispatcherHelper.CheckBeginInvokeOnUI(action);
        }
    }
}

【问题讨论】:

    标签: xamarin.forms prism mvvm-light


    【解决方案1】:

    据我所知,Prism 库中没有这样的东西。可能是因为 Xamarin.Forms 开箱即用:Device.BeginInvokeOnMainThread

    所以你可以去:

    namespace MyApp.iOS
    {
        public class DispatchOnUIThread : IDispatchOnUIThread
        {
            public void Invoke(Action action)
            {
                Device.BeginInvokeOnMainThread(action);
            }
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-08
      • 2014-06-12
      • 1970-01-01
      • 2022-11-28
      • 1970-01-01
      • 2018-07-10
      • 2023-04-10
      • 2011-01-19
      相关资源
      最近更新 更多