本文整理匯總了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();
}
}
}
}