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


C# EventHandler.Equals方法代码示例

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


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

示例1: Register

 public void Register(string eventID, EventHandler handler)
 {
     if (_registered.ContainsKey(eventID))
     {
         if (_registered[eventID].All(h => !handler.Equals(h)))
             _registered[eventID].Add(handler);
     }
     else
         _registered.Add(eventID, new List<EventHandler> {handler});
 }
开发者ID:paveyry,项目名称:MetaStruggle,代码行数:10,代码来源:EventManager.cs

示例2: StopAnimate

        /// <devdoc>
        ///     Removes an image from the image manager so it is no longer animated.
        /// </devdoc>
        public static void StopAnimate(Image image, EventHandler onFrameChangedHandler) {
            // Make sure we have a list of images                       
            if (image == null || imageInfoList == null) {
                return;
            }

            // Acquire a writer lock to modify the image info list - See comments on Animate() about this locking.

            bool readerLockHeld = rwImgListLock.IsReaderLockHeld;
            LockCookie lockDowngradeCookie = new LockCookie();

            threadWriterLockWaitCount++;

            try {
                if(readerLockHeld) {
                    lockDowngradeCookie = rwImgListLock.UpgradeToWriterLock(Timeout.Infinite);
                }
                else {
                    rwImgListLock.AcquireWriterLock(Timeout.Infinite);
                }
            }
            finally {
                threadWriterLockWaitCount--;
                Debug.Assert(threadWriterLockWaitCount >= 0, "threadWriterLockWaitCount less than zero.");
            }
            
            try {
                // Find the corresponding reference and remove it
                for(int i = 0; i < imageInfoList.Count; i++) {
                    ImageInfo imageInfo = imageInfoList[i];

                    if(image == imageInfo.Image) {
                        if((onFrameChangedHandler == imageInfo.FrameChangedHandler) || (onFrameChangedHandler != null && onFrameChangedHandler.Equals(imageInfo.FrameChangedHandler))) {
                            imageInfoList.Remove(imageInfo);
                        }
                        break;
                    }
                }
            }
            finally {
                if(readerLockHeld) {
                    rwImgListLock.DowngradeFromWriterLock(ref lockDowngradeCookie);
                }
                else {
                    rwImgListLock.ReleaseWriterLock();
                }
            }
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:51,代码来源:ImageAnimator.cs

示例3: StopAnimate

 public static void StopAnimate(Image image, EventHandler onFrameChangedHandler)
 {
     if ((image != null) && (imageInfoList != null))
     {
         bool isReaderLockHeld = rwImgListLock.IsReaderLockHeld;
         LockCookie lockCookie = new LockCookie();
         threadWriterLockWaitCount++;
         try
         {
             if (isReaderLockHeld)
             {
                 lockCookie = rwImgListLock.UpgradeToWriterLock(-1);
             }
             else
             {
                 rwImgListLock.AcquireWriterLock(-1);
             }
         }
         finally
         {
             threadWriterLockWaitCount--;
         }
         try
         {
             for (int i = 0; i < imageInfoList.Count; i++)
             {
                 ImageInfo item = imageInfoList[i];
                 if (image == item.Image)
                 {
                     if ((onFrameChangedHandler == item.FrameChangedHandler) || ((onFrameChangedHandler != null) && onFrameChangedHandler.Equals(item.FrameChangedHandler)))
                     {
                         imageInfoList.Remove(item);
                     }
                     return;
                 }
             }
         }
         finally
         {
             if (isReaderLockHeld)
             {
                 rwImgListLock.DowngradeFromWriterLock(ref lockCookie);
             }
             else
             {
                 rwImgListLock.ReleaseWriterLock();
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:50,代码来源:ImageAnimator.cs


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