當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。