本文整理汇总了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});
}
示例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();
}
}
}
示例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();
}
}
}
}