@@ -455,17 +455,7 @@ component {
455455 var instance = {' name' : instanceName ,' index' : index ,' task' : task ,' startDate' : now (),' iterations' : 0 ,' errors' : 0 ,' enabled' : true };
456456 instances [instanceName ]= instance ;
457457 try {inspectTemplates ();}catch (e ) {pagePoolClear ();} // older Lucee version do not support inspectTemplates...
458- // create the instance itself
459- try {
460- _log (" instantiate task [#instance .task .name #:#instance .index #]" );
461- if (! isNull (task .properties )) {
462- instance .cfc = new TaskForScheduler (task .name ,task .properties );
463- }
464- else instance .cfc = new " #task .name #" ();
465- }
466- catch (e ) {
467- _log (" failed to construct [#instance .task .name #]" ," error" ,e );
468- }
458+
469459
470460 thread name = instanceName owner = this engine = engine globalSwitch = globalSwitch activator = activator listeners = listeners instance = instance instances = instances {
471461 owner ._log (" start task instance [#instance .task .name #:#instance .index #]" );
@@ -479,6 +469,16 @@ component {
479469 // stopped in meantime?
480470 if ((! instance .enabled || (instance .task .paused ?: false ) || ! globalSwitch .enabled || ! engine .isRunning () || ! activator .active ())) break ;
481471
472+ // instantiate if not yet done
473+ if (! structKeyExists (instance , " cfc" )) {
474+ owner ._log (" constructing task instance [#instance .task .name #:#instance .index #]" );
475+ if (! isNull (instance .task .properties ))
476+ instance .cfc = new TaskForScheduler (instance .task .name , instance .task .properties );
477+ else
478+ instance .cfc = new " #instance .task .name #" ();
479+ owner ._log (" successfully constructed task instance [#instance .task .name #:#instance .index #]" );
480+ }
481+
482482 // execute
483483 var startDate = now ();
484484 var startTime = getTickCount ();
0 commit comments