based on customer requirement i realized a C# WCF web service that on each invocation starts a thread that performs asynchronous processing of its own. Once the thread is started, the web service ends its execution normally, regardless of the state of thread processing.
The problem i have is that sometimes, not always, the thread is interrupted randomly without any exception. The interruption takes place at different points and at different times so i am not able to identify a constant in its malfunction.
I report the piece of code of the service that starts the thread.
//WCF starts
....
//Starts a new thread
System.Threading.ThreadPool.QueueUserWorkItem(th =>
{
ThreadContext.Properties["property1"] = prop1;
// The class to be executed by the thread
ExecutionClass executionClass= new ExecutionClass();
Logger.log("start elaboration");
executionClass.start(parameter);
});
....
// the WCF returns the response independently of thread execution
return response;
May It be the windows or IIS that is causing thread ending? Can i do anything to fix this?
P.S. I know that is not a good solution to be implemented, but the requirements were imposed by the client.