Skip to Main Content
C# Cookbook, 2nd Edition
book

C# Cookbook, 2nd Edition

by Jay Hilyard, Stephen Teilhet
January 2006
Intermediate to advanced content levelIntermediate to advanced
1184 pages
43h 23m
English
O'Reilly Media, Inc.
Content preview from C# Cookbook, 2nd Edition
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
496
|
Chapter 9: Delegates, Events, and Anonymous Methods
invoked. One way to deal with this is to store all of the exceptions that occur during
delegate processing, then wrap all of the exceptions encountered during processing
in a custom exception. After processing completes, throw the custom exception. See
the
MyExceptionHoldingException class in the Solution.
By adding a
finally block to this try-catch block, you can be assured that code
within this
finally block is executed after every delegate returns. This technique is
useful if you want to interleave code between calls to delegates, such as code to clean
up objects that are not needed or code to verify that each delegate left the data it
touched in a stable state.
See Also
See Recipes 9.1 and 9.2; see the “Delegate Class” and “Delegate.GetInvocationList
Method” topics in the MSDN documentation.
9.4 Converting Delegate Invocation from
Synchronous to Asynchronous
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 converted
from synchronous to asynchronous mode.
Solution
A typical synchronous delegate type and supporting code that invokes the
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# Cookbook

C# Cookbook

Joe Mayo
C# Cookbook

C# Cookbook

Stephen Teilhet, Jay Hilyard
Head First C#, 4th Edition

Head First C#, 4th Edition

Andrew Stellman, Jennifer Greene

Publisher Resources

ISBN: 0596100639Supplemental ContentCatalog PageErrata