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


C# Visual.VerifyAccess方法代码示例

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


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

示例1: ConnectChild

        /// <summary>
        /// Sets the specified visual at the specified index into the child
        /// collection. It also corrects the parent.
        /// Note that the function requires that _item[index] == null and it
        /// also requires that the passed in child is not connected to another Visual.
        /// </summary>
        /// <exception cref="ArgumentException">If the new child has already a parent or if the slot a the specified index is not null.</exception>
        private void ConnectChild(int index, Visual value)
        {
            //
            // -- Approved By The Core Team --
            //
            // Do not allow foreign threads to change the tree.
            // (This is a noop if this object is not assigned to a Dispatcher.)
            //
            // We also need to ensure that the tree is homogenous with respect
            // to the dispatchers that the elements belong to.
            //
            _owner.VerifyAccess();
            value.VerifyAccess();
            
            // It is invalid to modify the children collection that we 
            // might be iterating during a property invalidation tree walk.
            if (_owner.IsVisualChildrenIterationInProgress)
            {
                throw new InvalidOperationException(SR.Get(SRID.CannotModifyVisualChildrenDuringTreeWalk));
            }

            Debug.Assert(value != null);
            Debug.Assert(_items[index] == null);
            Debug.Assert(value._parent == null);
            Debug.Assert(!value.IsRootElement);

            value._parentIndex = index;
            _items[index] = value;
            IncrementVersion();

            // Notify the Visual tree about the children changes. 
            _owner.InternalAddVisualChild(value);
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:40,代码来源:VisualCollection.cs


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