Previous Next

Unsubscribe( ) event method
Removes a method or procedure as a handler for an ABL or .NET class event.
Return type:
Access:
Applies to:
 
Syntax 
[ publisher : ] event-name:Unsubscribe
  ( [ subscriber : ] handler-method ) [ NO-ERROR ]
 
[ publisher : ] event-name:Unsubscribe
  ( [ subscriber-handle , ] handler-procedure ) [ NO-ERROR ]
[ publisher : ]
The object reference to an ABL or .NET object or the type name of an ABL or .NET class that can publish the instance or static event, respectively. If you do not specify a publisher, it defaults to either THIS-OBJECT when event-name identifies an instance event defined in the current class instance, or to the class type name of the current class definition when event-name identifies a static event defined in the current class hierarchy.
event-name
The name of an ABL or .NET event that publisher can publish. At compile time, ABL verifies that event-name is an accessible member of the class referenced by publisher. The event can be an abstract event.
 
 
[ subscriber : ] handler-method
An ABL class-based method that you want to remove as a handler for event-name, where handler-method is the unquoted name of the instance or static method. If specified, subscriber can be either the object reference to an ABL class instance where handler-method is defined, or the type name of an ABL class where the static handler-method is defined. If you do not specify a subscriber, it defaults to THIS-OBJECT when handler-method identifies an instance method defined in the current class hierarchy, or to the class type name of the current class definition when handler-method identifies a static method defined in the current class hierarchy.
Note that the access mode (PUBLIC, PROTECTED, or PRIVATE) of the handler-method definition does not matter to the publisher. For example, you can remove a PRIVATE method of the unsubscribing class instance as a handler for an event defined and published by yet another class instance.
The signature of handler-method must be run-time compatible with the signature defined for event-name. This includes an overloaded method as long as ABL can identify the signature for a unique overloading that is compatible with the event signature.
Thus, ABL raises a compile-time error if handler-method:
*
Is not accessible to the context where this Unsubscribe( ) method executes
*
*
[ subscriber-handle , ] handler-procedure
A procedure that you want to remove as a handler for event-name, where handler-procedure is a character expression that evaluates to the name of an internal procedure. If specified, subscriber-handle is a handle to a persistent procedure, or other external procedure on the call stack, where the internal procedure is defined. Otherwise, subscriber-handle defaults to THIS-PROCEDURE.
At compile-time, ABL checks this Unsubscribe( ) method call only to verify that any specified subscriber-handle is a HANDLE data type and that handler-procedure is specified by a character expression. Otherwise, ABL raises a run-time error if the procedure context specified by subscriber-handle is not accessible or it does not define handler-procedure as an internal procedure.
NO-ERROR
Suppresses ABL errors or error messages that would otherwise occur and diverts them to the ERROR-STATUS system handle. If an error occurs, the action of the statement is not completed and execution continues with the next statement. If the statement fails, any persistent side-effects of the statement are backed out. If the statement includes an expression that contains other executable elements, like methods, the work performed by these elements may or may not be completed, depending on the order in which the AVM resolves the expression elements and the occurrence of the error.
To check for errors after a statement that uses the NO-ERROR option:
*
*
*
Use ERROR-STATUS:GET-MESSAGE( message-num ) to retrieve a particular message, where message-num is 1 for the first message.
If the statement does not include the NO-ERROR option, you can use a CATCH end block to handle errors raised by the statement.
Following are some other important usage notes on the NO-ERROR option:
*
*
*
*
*
The Unsubscribe( ) method cancels an event subscription by removing the specified method or internal procedure from the list of handlers for the specified event-name. If you do not specify a publisher, you can only invoke Unsubscribe(  ) in an ABL class definition and on an ABL or .NET event that the ABL class defines or inherits. When you cancel an event handler subscription, ABL does not raise either a run-time error if the specified event handler is not currently on the subscription list for the specified event.
See also:
 

Previous Next
© 2013 Progress Software Corporation and/or its subsidiaries or affiliates.