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 } }
static bool CheckAccess() { #if WinRT return(dispatcher == null || Window.Current != null); #else return(dispatcher == null || dispatcher.CheckAccess()); #endif }
private bool CheckAccess() { #if WINDOWS_UWP return(dispatcher == null || Window.Current != null); #else return(dispatcher == null || dispatcher.CheckAccess()); #endif }