Possible Duplicate:
WCF Windows Service - Long operations/Callback to calling module
I have a WCF application hosted on windows service. I have to use basicHttpBinding. In the application, I make a long-term analysis of the data, and then turn them into customers.
Is it possible to call WCF creating a thread that will be carried out analysis (Id of this thread will be sent to the client)?
The client should be able to communicate with the theme of using the transmitted ID and, if it receives information that the data is ready, it should be able to be downloaded. This will, in turn, release the thread.
How can I achieve this functionality?
Ok. It works. Client method call creates a thread that even after paying guid runs in the background and saves the result of the operation. How best can store these results? Due to the fact that the service is running Per Call dictionary resets with each calling the service. Declaring static data can be overridden, but I do not think it was a good idea. Any ideas?
namespace WCFRiskService
{
[ServiceContract]
public interface IRiskService
{
// return Thread ID
[OperationContract]
int GetAnalysis(AnalysisId);
[OperationContract]
string GetAnalysisData(int ThreadId);
}
public class Analysis
{
public GenerateAnalysis()
{
Thread.Sleep(20000);
Analysis = "Generated Data";
}
}
public class RiskService : IRiskService
{
// How can I change this, to use non-static objects ?
static string AnalysisData = "";
public string GetAnalysisData(int ThreadId);
{
return AnalysisData;
}
public int GetAnalysis(AnalysisId);
{
Analysis AObject = new Analysis();
AObject.Tree = AnalysisTree;
Thread workerThread = new Thread(AObject.GenerateAnalysis);
int managedThreadId = workerThread.ManagedThreadId;
workerThread.Start();
while (!workerThread.IsAlive) ;
return managedThreadId;
}
}
}