ADBRITE ads links
You are here: CodeIdol.com > C# > C# Cookbook, 2nd Edition > Delegates, Events, And Anonymous Methods
C# Cookbook, 2nd Edition
| Problem:
You have combined multiple delegates to create a multicast delegate. When this multicast delegate is fired, each delegate within it is fired in turn. You need to exert more control over such things as the order in which each delegate is fir...
|
|
| Problem:
You have added multiple delegates to a single multicast delegate. Each of these individual delegates returns a value that is required by your application. Ordinarily, the values returned by individual delegates in a multicast delegate are l...
|
|
| Problem:
You have added multiple delegates to a single multicast delegate. Each of these individual delegates must be invoked, regardless of whether an unhandled exception is thrown within one of the delegates. But once a delegate in a multicast del...
|
|
| Problem:
You have determined that one or more delegates invoked synchronously within your application are taking a long time to execute. This delay is making the user interface less responsive to the user. The invocation of these delegates should be...
|
|
| Problem:
Through the use of inheritance, adding events to a nonsealed class is fairly easy. For example, inheritance is used to add events to a Hashtable object. However, adding events to a sealed class, such as System.IO.DirectoryInfo, requires a t...
|
|
| Problem:
You have implemented Recipe 9.5, but you want to allow an event listener to cancel an action that raised a particular event. For example, if a class attempts to create a new directory, you want to be able to verify that the directory is bei...
|
|
| Problem:
You are searching for an interface using the Type class. However, complex interface searches are not available through the GetInterface and GetInterfaces methods of a Type object. The GetInterface method searches for an interface only by na...
|
|
| Problem:
You are searching for a member within a type using the Type class. However, complex member searches are not available through the GetMember and GetMembers methods of a Type object. The GetMember method searches for a member name only within...
|
|
| Problem:
You have multiple objects that need to observe modifications to a Hashtable. When an item is added or modified in the Hashtable, each of these observer objects should be able to vote to allow or disallow the action. In order for an action t...
|
|
| Problem:
You need to watch and respond to specific user keyboard input, and, based on the input, you want to perform one or more actions. For example, pressing the Windows key and the E key at the same time launches Windows Explorer. You would like ...
|
|
| Problem:
Many new mice have more than just a left and right button. Nowadays, mice come with several additional buttons and a mouse wheel. You need to allow your application to take advantage of these new mice features. Additionally, you might need ...
|
|
| Problem:
There is a new feature in C# 2.0 called anonymous methods. While anonymous methods can be viewed as syntactic sugar for making delegate calls less difficult, you want to understand all of the different ways that they can be used to help you...
|
|
| Problem:
In versions of the .NET Framework previous to 2.0, the System.EventHandler delegate could be used on events in which the arguments were always of type System.EventArgs. This was great if you really didn't care about any data that went along...
|
|
| Problem:
You know you can pass parameters to anonymous methods but you need to figure out what parameter modifiers are valid with anonymous methods.
Solution:
Anonymous methods can use out and ref parameter modifiers but not the params modifie...
|
|
| Problem:
You want to associate a small amount of state with some behavior without going to the trouble of building a new class.
Solution:
Use anonymous methods to implement closures. Closures can be defined as functions that capture the state ...
|
|
| Problem:
You want to be able to perform multiple operations on an entire collection of objects at once, while keeping the operations functionally segmented.
Solution:
Use a functor (or function object as it is also known) as the vehicle for tr...
|
|
You are here: CodeIdol.com > C# > C# Cookbook, 2nd Edition > Delegates, Events, And Anonymous Methods
|
|
Related tags
Popular Categories
Unix books and guides
AJAX popular information
C# language guides
Windows books and cookbooks
.......
|
|