This topic discusses general application behavior.

  1. Application developers should make every effort to ensure that event handlers and method callbacks do not throw exceptions back to the platform. The platform does not have code to catch exceptions that are uncaught by an application, so any such exceptions that are thrown have the potential to cause the application to crash.

  2. If the application blocks a worker thread that is raising an event or invoking a callback, subsequent events will not be delivered until the callback returns. However, this behavior will not interfere with the completion of any pending operations.

  3. An application should avoid blocking inside an event handler or callback.

  4. The application should catch InvalidOperationExceptionwhen calling any Begin Xxxmethod of the platform.

  5. The application should not call End Xxxmore than once.

  6. Some objects will not be garbage collected until the application terminates them. For example, an endpoint will maintain strong references to conversations. Unless a conversation is terminated, it will not be released from the endpoint. The application is responsible for terminating any such components.

  7. Some components might terminate themselves under certain circumstances, causing a state change event to inform the application that the component has been terminated. In such cases, the application need not terminate the component again. However, if an application chooses to terminate the component again, it is free to do so, and the termination operation is expected to work. For example, a client conversation will terminate itself when the last established call is terminated.

  8. If the platform exposes a collection to the application, what is returned is a snapshot of the actual internal collection; hence it should be safe for the application to enumerate that collection. Any changes that are made to the original collection after getting the snapshot will not be reflected in the collection returned to the application. Thus, it is recommended that the application use events to keep track of collections rather than access the property that returns a snapshot.

  9. The platform exposes a static class called UnhandledExceptionManagerwith a single property that represents a delegate. The application is expected to set this delegate so that the platform can report unhandled exceptions that occur in worker threads used by the application. If the delegate returns true, such exceptions are ignored. Otherwise, the exception is rethrown, potentially resulting in a process crash.