CreateTaskEvent (TdbmEvent)
De Wiki1000
class procedure CreateTaskEvent(const iEventId:string; iNames:Array of variant; iValues:Array of variant);
Cette méthode de classe crée un événement de type tâche.
Le type de l'événement est TASK
iEventId | identifiant de l'événement |
iNames | Tableau de noms de paramètre de l'évènement |
iValues | Tableau de valeurs de paramètre de l'évènement |
Exemple :
// Task to be triggered by an event Type TMyOperationEvent = class(TitTask) function Execute():Integer; class function RegisterThisTask; class procedure Start; end; function TMyOperationEvent.Execute():Integer; var idx:Integer; S:string; aMsg:TdbmQueueMessage; begin Result := True; // Add messages to the log ProgressMessage('On Task event'); if Assigned(UserContext.TaskContext) and Assigned(userContext.TaskContext.EventContext) then begin userContext.TaskContext.AddMessage('Task context'); // aMsg := userContext.TaskContext.EventContext.ReceivedMsg; if Assigned(aMsg) then begin // get message parameters // userContext.TaskContext.AddMessage('Task context has message'); userContext.TaskContext.AddMessage(Format('Message parameter count:%d',[aMsg.Count])); for idx:=0 to aMsg.Count-1 do begin S := aMsg.DisplayStrings(idx); UserContext.TaskContext.AddMessage(S); end; end; end else ProgressMessage('no task context'); Result := True; end; class function TMyOperation.RegisterThisTask; var aReason:string; begin if not SubscribeToEvent(TMyOperation.OnStartId(),aReason) then showMessage('subscribe failed '+aReason); end; class procedure TMyOperation.Start; begin TdbmEvent.CreateTaskEvent(TMyOperation.OnStartId(), ['name1','name2'],['value1',2]); end;
Voir aussi :