Beispiel #1
0
        public void Invoke(T parameter)
        {
            if (dispatcher != null)
            {
                bool access;

#if NETFX_CORE
                access = dispatcher.HasThreadAccess;
#else
                access = dispatcher.CheckAccess();
#endif

                if (access)
                {
                    ExecuteCallback(parameter);
                }
                else
                {
#if NETFX_CORE
                    dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => ExecuteCallback(parameter));
#else
                    dispatcher.BeginInvoke(new Action(() => ExecuteCallback(parameter)));
#endif
                }
            }
            else
            {
#if NETFX_CORE
                ThreadPool.RunAsync((x) => ExecuteCallback(parameter));
#else
                ThreadPool.QueueUserWorkItem((x) => ExecuteCallback(parameter));
#endif
            }
        }
Beispiel #2
0
        static bool CheckAccess()
        {
#if WinRT
            return(dispatcher == null || Window.Current != null);
#else
            return(dispatcher == null || dispatcher.CheckAccess());
#endif
        }
Beispiel #3
0
        private bool CheckAccess()
        {
#if WINDOWS_UWP
            return(dispatcher == null || Window.Current != null);
#else
            return(dispatcher == null || dispatcher.CheckAccess());
#endif
        }