Reputation: 193
Is it possible to created a function in a web service to have multiple threads, one which returns a value to the user, and one that continues to process a transaction? I've never used any multithreading before and it seems like I would be able too by running the transaction Asynchronously. No code has been written yet. Trying to see if it is possible before I begin coding.
Upvotes: 1
Views: 4228
Reputation: 29668
Although you CAN fire off threads and the like, much like any other .NET application you have to take into account your operating environment.
Any long running process should really be handed off to another process like a Windows service as web server worker processes can and do get recycled and with it goes your threads. You're also tying up threads that could be used to further service requests to the web application.
In regards to what Paul Abbot said, in principle if you had a way of returning some kind of work ID to the client you could poll the status of the processing in another request, and this can apply within the same process or out of process in an external service.
Upvotes: 1