Create a long running task in XData service

Hi,
this might me more general delphi multitasking related issue than Xdata, but just wondering if there something in xdata that would help with our problem.
I'd like to create a long running task.
First call to task would start task and return immediately with result " task started with url to querystatus service".

While task is running other call to same service with same parameters would return "already started".
I tried to use ITask for that, which was declared as service class field. This caused av's cause I assume that service method class is destroyed when service method exits and I task is of course destroyed at same time.

I think I need to create global dictionary of objects which hold that Itask... Or do you have better ideas?

It seems you indeed has to store somewhere the keys representing those threads. Either a dictionary in memory, or maybe something in the database, so it's more scalable, if you need that.