ExecuteAsTask (TTaskConfigureController)

De Wiki1000
(Différences entre les versions)
(Page créée avec « <source lang='delphi'>function ExecuteAsTask(var aReason:string):boolean;</source> Cette méthode exécute la tâche en asynchrone. {|class="wikitable" |- |Result |True ... »)
 
Ligne 16 : Ligne 16 :
  
 
<source lang="delphi">
 
<source lang="delphi">
 +
function doExecuteMyTask:string;
 +
var inst:TTaskFormController; myCallBack:myCallBackTask; aReason:string;
 +
begin
 +
  // Instance of the call which must be called after execution of the task
 +
  // Just need to retreive the EventID of the call back
 +
  myCallBack := myCallBackTask.Create;
 +
 +
  inst := TTaskFormController.Create;
 +
 +
  // Previously configured parameters
 +
  inst.TaskParameters := myProcessusParameters;
 +
 +
  // In the case the task generate a document (for example a report)
 +
  // We want to generate a document and to attach it to the main object
 +
  // (The main object may be any persistent object)
 +
  inst.DocumentAttachOID := mainObject.InstanceOID;
 +
 +
  // We want to generate an event to execute asynchronously a call back
 +
  inst.TaskEventID := myCallBack.EventID;
 +
 +
  // We want to retreive the log entry for this task
 +
  inst.TaskReference := InstanceOID;
 +
 +
  // Execute asynchronously
 +
  inst.ExecuteAsTask(aReason);
 +
end;
 
</source>
 
</source>
  

Version du 20 novembre 2019 à 16:23

function ExecuteAsTask(var aReason:string):boolean;

Cette méthode exécute la tâche en asynchrone.

Result True : Succès, False : Erreur de création de la tâche
aReason Information sur l'erreur


Exemple :

function doExecuteMyTask:string;
var inst:TTaskFormController; myCallBack:myCallBackTask; aReason:string;
begin
  // Instance of the call which must be called after execution of the task
  // Just need to retreive the EventID of the call back
  myCallBack := myCallBackTask.Create;
 
  inst := TTaskFormController.Create;
 
  // Previously configured parameters
  inst.TaskParameters := myProcessusParameters;
 
  // In the case the task generate a document (for example a report)
  // We want to generate a document and to attach it to the main object
  // (The main object may be any persistent object)
  inst.DocumentAttachOID := mainObject.InstanceOID; 
 
  // We want to generate an event to execute asynchronously a call back
  inst.TaskEventID := myCallBack.EventID;
 
  // We want to retreive the log entry for this task
  inst.TaskReference := InstanceOID;
 
  // Execute asynchronously
  inst.ExecuteAsTask(aReason);
end;

Voir aussi

TTaskFormController_(class)Développement DSM

Outils personnels