Hi, it is safe to create threads on a service operation
I have a service that saves data to the database on the Service operation and need to call a Webservice from a external server to retrieve aditional data, and save it to the database, for this I use a thread on the service method(Client doesnt need to wait for aditional data to be retrieve from external server for the call to the service operation to be ok).
Some thing like this:
aThread : TThread;
IDConnection : IDBConnection;
/// Get connection from connection pool.
/// save sent data on DB
IDConnection := TXDataOperationContext.Current.GetConnectionPool.GetConnection;
aThread := TThread.CreateAnonymousThread(procedure ()
Manager : TObjectManager;
Manager := TObjectManager.Create(IDConnection);
/// call remote webservices and save responses to database
/// may take from seconds to a few minutes to complete, depends on the remote server load.
IDConnection := nil;
Is the above code ok? will the call to the ServerData return the connection to the connection pool and also the thread code will return the
connection to the connection pool when finished?
Thanks in advance,