# system.util.invokeAsynchronous

**URL:** <https://forum.inductiveautomation.com/t/system-util-invokeasynchronous/22057>\
**Category:** Ignition\
**Created:** [January 23, 2019, 12:51pm UTC](https://forum.inductiveautomation.com/t/system-util-invokeasynchronous/22057 "2019-01-23T12:51:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![eduardo.ojalvo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/eduardo.ojalvo/32/14356_2.png) [@eduardo.ojalvo](https://forum.inductiveautomation.com/u/eduardo.ojalvo)\
**Post date:** [January 23, 2019, 12:51pm UTC](https://forum.inductiveautomation.com/t/system-util-invokeasynchronous/22057/1 "2019-01-23T12:51:51Z")

</div>

Hi everybody.

I have the next code to allow the ignition system working in background while query with the other system is working in other way.  
well, it not working i don´t know why , any idea?  
The ignition is locked while query is being processed.

Thank you very much.

Eduardo.

```auto
p1=event.source.parent.zona
p2=event.source.parent.f_ini
p3=event.source.parent.f_fin
lotes=project.lotes.lotes(p1,p2,p3)
event.source.parent.getComponent('Power Table').data= system.dataset.toDataSet(lotes)

def async():
                TABLA='APROL_DB'
                texto='where'

                               
                for row in lotes:
                               zona=row["ZONA"]
                               f_ini=row["FECHA INICIO"]
                               f_ini=system.db.dateFormat(f_ini, "yyyy-MM-dd HH:mm:ss")
                                               
                               f_fin=row["FECHA FIN"]
                               f_fin=system.db.dateFormat(f_fin, "yyyy-MM-dd HH:mm:ss")
                               
                               if texto=='where':
                                               texto=texto+'(ts>'+"'"+f_ini+"'"+' AND ts<'+"'"+f_fin+"'"+' AND alias like '+"'"+zona+"'"+')'
                               else:
                                               texto=texto+' OR (ts>'+"'"+f_ini+"'"+' AND ts<'+"'"+f_fin+"'"+' AND alias like '+"'"+zona+"'"+')'
                                               #texto=texto+fecha
                               #system.gui.messageBox(texto)
                texto_estatico='SELECT ts "FECHA/HORA",priority "PRIORIDAD",`group` "AGRUPACION",pv "VARIABLE",flags "MARCA",alias "ZONA",begin_ts "FECHA/HORA INIC.",end_ts "FECHA/HORA FIN",round(duration/1000,0) "DURACION",ack_ts "FECHA/HORA REC.",ack_text "TEXTO REC.",username "USUARIO",text "DESCRIPCION" FROM Alarm'
                texto_fin=texto_estatico+" "+texto
                               #system.gui.messageBox(texto_fin)
                def later():
                               system.gui.messageBox("estoy en later")
                               if lotes.getRowCount()!=0:
                                               resultado_q=system.db.runQuery(texto_fin,TABLA)   
                                               event.source.parent.getComponent('Power Table APROL').data=resultado_q
                               else:
                                               system.gui.messageBox("NO EXISTE NINGUN LOTE REGISTRADO CON ESAS RESTRICCIONES")
                               
                system.util.invokeLater(later)
#event.source.parent.getComponent('Animated Gif').visible=0
system.util.invokeAsynchronous(async)

```

---

<div class="post-metadata">

**Author:** ![nick.schuetz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nick.schuetz/32/6160_2.png) [@nick.schuetz](https://forum.inductiveautomation.com/u/nick.schuetz)\
**Post date:** [January 23, 2019, 1:54pm UTC](https://forum.inductiveautomation.com/t/system-util-invokeasynchronous/22057/2 "2019-01-23T13:54:35Z")

</div>

It looks like you run the actual query in the invokeLater callback. I’m pretty sure that section isnt called asynchronously, which is why you can interact with gui objects. Try moving the query call out of the later() function and into the asychronous call, and pass the results into the later callback.

---

<div class="post-metadata">

**Author:** ![eduardo.ojalvo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/eduardo.ojalvo/32/14356_2.png) [@eduardo.ojalvo](https://forum.inductiveautomation.com/u/eduardo.ojalvo)\
**Post date:** [January 23, 2019, 4:10pm UTC](https://forum.inductiveautomation.com/t/system-util-invokeasynchronous/22057/3 "2019-01-23T16:10:41Z")

</div>

You are on true.

Thank you very much.
