I have a WCF service which will get an object with huge data from database in the form of collection. I have a UI which has get and cancel buttons .
Get button : make service request and continue with data population with the returned data from service.I start it as below
Thread _workerThread = new Thread(DoExportTreeLoad); _workerThread.Start();
Cancel : stops the above thread.It does as below
My DoExportTreeLoad() has the synchronous service call which in turn hits database and gets data.
result = serivce.GetData(criteria);
Problem: When I cancel the operation after requesting the service, the DAL code is still running in the background (getting data from database) where it should not happen.
As soon as i cancel the operation from UI ,the transaction (to get the data ) from database need to be aborted. It leads to big performance problem.
Please help me with any way to end up the backend task when thread is cancelled. Thanks in advance.