|Navigation: Language Reference > 13 - Built-in Functions >====== NOTIFY (send safe information to a receiver thread) ======|
NOTIFY( notifycode, <;thread>, <;parameter> )
|NOTIFY||Sends an event and optional parameter to a receiving thread.|
|notifycode||An unsigned integer value that indicates the notification or request code.|
|thread||A signed integer that identifies the number of the receiver thread; if omitted or equal to 0, the current thread is the receiver.|
|parameter||An optional LONG value that is used as a parameter of the notification or request|
The NOTIFY statement is called on the sender side. It generates the EVENT:Notify event and places it at the front of the event queue of receiver's thread top window. Generally, the EVENT:Notify event is a special event that can transfer up to 2 additional parameters (thread and parameter) to the receiver.
Execution of the sender thread continues immediately. It does not wait for any response from the receiver.
NOTIFY and NOTIFICATION are a functional replacement for the SETTARGET(,thread) statement. They can also be used for safe transfer information between threads.
The code between SETTARGET(,thread) and a subsequent SETTARGET is executing in the context of the specified thread but also as a part of the current thread. Hence, two threads can execute the code in the same context. Also, related DLLs can associate their thread dependent data with the Thread ID of the current thread. These aspects make using SETTARGET(,thread) potentially dangerous in the new threading model.
The purpose of NOTIFY and NOTIFICATION is to provide a way to send a notification with parameters from one thread to another. The receiver thread can then execute the request in the correct context.
SELF.NofWindows = 0
NOTIFY (NOTIFY:Load, 1, ADDRESS (SELF.IDynMenu)) !Send Notify event to primary thread
NOTIFY (NOTIFY:Unload, 1, ADDRESS (SELF.IDynMenu))