当前位置: 首页>>代码示例>>C#>>正文


C# this.CheckAccess方法代码示例

本文整理汇总了C#中this.CheckAccess方法的典型用法代码示例。如果您正苦于以下问题:C# this.CheckAccess方法的具体用法?C# this.CheckAccess怎么用?C# this.CheckAccess使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在this的用法示例。


在下文中一共展示了this.CheckAccess方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: NecessityInvoke

        public static void NecessityInvoke(this Dispatcher self, Action action)
        {
            if (self.CheckAccess())
                action();

            self.Invoke(action);
        }
开发者ID:truongan012,项目名称:Pulse,代码行数:7,代码来源:DispatcherExm.cs

示例2: adoptAsync

 public static void adoptAsync(this Dispatcher dispatcher, Action del)
 {
     if(dispatcher.CheckAccess())
         del();
     else
         dispatcher.BeginInvoke(del);
 }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:7,代码来源:DispatcherExtensions.cs

示例3: InvokeIfRequired

 public static void InvokeIfRequired(this Dispatcher dispatcher, Action action, DispatcherPriority priority)
 {
     if (!dispatcher.CheckAccess())
     dispatcher.Invoke(priority, (Delegate) action);
       else
     action();
 }
开发者ID:unbearab1e,项目名称:FlattyTweet,代码行数:7,代码来源:DispatcherExtensions.cs

示例4: InvokeOnUIThread

        /// <summary>
        /// Executes an action on the UI thread, waiting for the action to complete.<br/>
        /// If this method is called from the UI thread, the action is executed immediately.<br/>
        /// If the method is called from another thread, the action will be enqueued on the UI thread's dispatcher
        /// and executed synchronously.
        /// </summary>
        /// <param name="dispatcher">Dispatcher instance.</param>
        /// <param name="action">Action to execute.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="dispatcher"/> is <see langword="null"/>.
        ///     <para>-or-</para>
        /// <paramref name="action"/> is <see langword="null"/>.
        /// </exception>
        public static void InvokeOnUIThread(this Dispatcher dispatcher, Action action)
        {
            if (dispatcher == null)
            {
                throw new ArgumentNullException("dispatcher");
            }

            if (action == null)
            {
                throw new ArgumentNullException("action");
            }

            if (dispatcher.CheckAccess())
            {
                action();
            }
            else
            {
                using (ManualResetEventSlim resetEvent = new ManualResetEventSlim(false))
                {
                    dispatcher.BeginInvoke(() =>
                    {
                        action();
                        resetEvent.Set();
                    });

                    resetEvent.Wait();
                }
            }
        }
开发者ID:trilok567,项目名称:Windows-Phone,代码行数:43,代码来源:DispatcherEx.cs

示例5: VerifyAccess

 /// <summary>
 /// Determines whether the calling thread has access to this Dispatcher. 
 /// </summary>
 /// <param name="dispatcher"></param>
 /// <remarks>Only the thread the Dispatcher is created on may access the Dispatcher. 
 /// This method is public; therefore, any thread can check to see whether it has access to the Dispatcher.
 /// The difference between CheckAccess and VerifyAccess is CheckAccess returns a Boolean if the calling thread does 
 /// not have access to the Dispatcher and VerifyAccess throws an exception.
 ///</remarks>
 public static void VerifyAccess(this Dispatcher dispatcher)
 {
     if (!dispatcher.CheckAccess())
     {
         throw new InvalidOperationException("Cross-thread operation not valid");
     }                
 }
开发者ID:modulexcite,项目名称:IL2JS,代码行数:16,代码来源:Extensions.Silverlight.cs

示例6: SyncInvoke

 public static void SyncInvoke(this Dispatcher dispatcher, Action action)
 {
    if (dispatcher.CheckAccess())
       action();
    else
       dispatcher.Invoke(action);
 }
开发者ID:Sugz,项目名称:Outliner-3.0,代码行数:7,代码来源:DispatcherExtensions.cs

示例7: BeginInvokeAfterTimeout

        /// <summary>
        /// Executes the specified action asynchronously on the thread the Dispatcher is associated with, after the specified timeout.
        /// </summary>
        /// <param name="dispatcher">The dispatcher instance.</param>
        /// <param name="timeout">The <see cref="TimeSpan"/> representing the amount of time to delay before the action is invoked.</param>
        /// <param name="action">The <see cref="Action"/> to execute.</param>
        public static void BeginInvokeAfterTimeout(this Dispatcher dispatcher, TimeSpan timeout, Action action)
        {
            if (!dispatcher.CheckAccess())
            {
                dispatcher.BeginInvoke(() => dispatcher.BeginInvokeAfterTimeout(timeout, action));
            }
            else
            {
                var dispatcherTimer = new DispatcherTimer()
                {
                    Interval = timeout
                };

                dispatcherTimer.Tick += (s, e) =>
                {
                    dispatcherTimer.Stop();

                    dispatcherTimer = null;

                    action();
                };

                dispatcherTimer.Start();
            }
        }
开发者ID:HamGuy,项目名称:Cimbalino-Phone-Toolkit,代码行数:31,代码来源:DispatcherExtensions.cs

示例8: GetPropertyValue

 public static object GetPropertyValue(this DependencyObject o, DependencyProperty prop)
 {
     if (o.CheckAccess())
         return o.GetValue(prop);
     return o.Dispatcher.Invoke(new Func<DependencyObject, DependencyProperty, object>(GetPropertyValue),
                                o,
                                prop);
 }
开发者ID:minustar,项目名称:MinustarDictionaries,代码行数:8,代码来源:DispatcherExtensions.cs

示例9: InvokeOrExecute

 public static void InvokeOrExecute(this Dispatcher dispatcher, Action action)
 {
     if (dispatcher.CheckAccess()) {
         action();
     } else {
         dispatcher.BeginInvoke(DispatcherPriority.Normal, action);
     }
 }
开发者ID:poqdavid,项目名称:SAPPRemote,代码行数:8,代码来源:Extensions.cs

示例10: DoAsync

        private static Task DoAsync(this Dispatcher dispatcher, Action action)
        {
            if (!dispatcher.CheckAccess())
            {
                return RunAsync(dispatcher, action);
            }

            return RunSynchronously(action);
        }
开发者ID:kazyx,项目名称:SvgToXaml,代码行数:9,代码来源:DispatcherExtensions.cs

示例11: CheckAccess

        public static bool CheckAccess(this IAuthorizationService authorizationService, IPrincipal principal, Operation operation, Resource resource)
        {
            var claimsPrincipal = principal.AsClaimsPrincipal();
            var resources = new Collection<Claim>(new Claim[] { resource }.ToList());
            var operations = new Collection<Claim>(new Claim[] { operation }.ToList());

            var authorizationContext = new AuthorizationContext(claimsPrincipal, resources, operations);

            return authorizationService.CheckAccess(authorizationContext);
        }
开发者ID:noopman,项目名称:FunnelWeb,代码行数:10,代码来源:IAuthorizationService.cs

示例12: SetPropertyValue

 public static void SetPropertyValue(this DependencyObject o, DependencyProperty prop, object value)
 {
     if (o.CheckAccess())
         o.SetValue(prop, value);
     else
         o.Dispatcher.Invoke(new Action<DependencyObject, DependencyProperty, object>(SetPropertyValue),
                             o,
                             prop,
                             value);
 }
开发者ID:minustar,项目名称:MinustarDictionaries,代码行数:10,代码来源:DispatcherExtensions.cs

示例13: Do

        private static void Do(this Dispatcher dispatcher, Action action)
        {
            if (!dispatcher.CheckAccess())
            {
                dispatcher.BeginInvoke(action, DispatcherPriority.Background);
                return;
            }

            action();
        }
开发者ID:kazyx,项目名称:SvgToXaml,代码行数:10,代码来源:DispatcherExtensions.cs

示例14: RunAsync

 /// <summary>
 /// Invokes the specified action asynchronously using the <see cref="Dispatcher"/> if required.
 /// </summary>
 /// <param name="dispatcher">The dispatcher.</param>
 /// <param name="action">The action.</param>
 /// <returns>A task containing the invoked action.</returns>
 public static async Task RunAsync(this Dispatcher dispatcher, Action action)
 {
     if (dispatcher.CheckAccess())
     {
         action();
     }
     else
     {
         await dispatcher.InvokeAsync(() => RunAsync(dispatcher, action));
     }
 }
开发者ID:ruisebastiao,项目名称:Elysium-Extra,代码行数:17,代码来源:DispatcherExtensions.cs

示例15: SmartBeginInvoke

 public static void SmartBeginInvoke(this Dispatcher dispatcher, Action a)
 {
     if (dispatcher.CheckAccess())
     {
         a.Invoke();
     }
     else
     {
         dispatcher.BeginInvoke(a);
     }
 }
开发者ID:CuiXiaoDao,项目名称:tinder,代码行数:11,代码来源:DispatcherExtensions.cs


注:本文中的this.CheckAccess方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。