| **Navigation:**  [[introduction.htm|Language Reference]] > 13 - Built-in Functions >====== NOTIFICATION (receive information from sender thread) ====== | [[nomemo read file record without reading memo .htm|{{btn_prev_n.gif|Previous page}}]][[introduction.htm|{{btn_home_n.gif|Return to chapter overview}}]][[notify send safe information to a receiver thread .htm|{{btn_next_n.gif|Next page}}]] | | || **NOTIFICATION(**//notifycode, <;thread>, <;parameter> //**)** {{blk2blue.jpg|blk2blue.jpg}} | **NOTIFICATION** | Receives information from a sender thread. | | //notifycode// | An UNSIGNED variable that receives a notify code value passed by the sender with a NOTIFY statement. | | //thread// | An optional SIGNED variable that receives the number of the sender's thread parameter. | | //parameter// | A LONG variable that receives the parameter passed by the sender with a NOTIFY statement. | The **NOTIFICATION** function is used by a receiving thread. It receives the notification code, thread number, and parameter passed by the sending thread's [[notify send safe information to a receiver thread .htm|NOTIFY]] statement. **NOTIFICATION** returns FALSE (0) if the EVENT() function returns an event other than EVENT:Notify. If EVENT:Notify is posted, **NOTIFICATION** returns TRUE. Because calls to NOTIFY and **NOTIFICATION** are asynchronous, the sender thread can be closed already when receiver thread accepts the EVENT:Notify event. 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. **Return Data Type:**     BYTE **Example:** **CASE EVENT()** ** OF EVENT:Accepted** **  CASE ACCEPTED()** **  OF ?Start** **   START (T1)** **  OF ?Load** **   CALL ('DLL.DLL', 'EntryPoint', 1)** **  ELSE** **   Q.Feq = ACCEPTED()** **   GET (Q, Q.Feq)** **   IF ERRORCODE() = 0 AND Q.Op <;> 0** **    DM &= Q.ID + 0** **    DM.ExecuteMenu (Q.Op)** **   END** **  END** ** OF EVENT:Notify** **  IF ****NOTIFICATION**** (NCode,, NParam) !NOTIFY has sent a Notify Event. Get Code and Parameter** **   DM &= NParam + 0                !Assign passed parameter to reference var** **   CASE Ncode                      !Test the Notify Code** **   OF NOTIFY:Load** **    DM.CreateMenu (Q)              !Execute appropriate action** **   OF NOTIFY:Unload** **    DO DestroyMenu** **    UNLOAD ('DLL.DLL')             !Execute appropriate action** **   END** **  END** ** END** **See Also:** [[notify send safe information to a receiver thread .htm|NOTIFY]]