dispatcherObject.CheckAccess

        /// <summary>
        /// The dispatcher object.
        /// </summary>
        private readonly DispatcherObject _dispatcherObject;


       #region Constructor
        public [Constructor]()
        {
            _dispatcherObject = Application.Current;
        }
        #endregion

 void [XXXFunction]()
        {
            if (!_dispatcherObject.CheckAccess())
            {
                _dispatcherObject.Dispatcher.Invoke(new Action(XXXFunction));
                return;

  //maybe all main thread.
            }

原文地址:https://www.cnblogs.com/xiaokang088/p/3116422.html