My contract has request-reply operation which performs multiple tasks. So I would like to inform about the progress of the operation to the client as its a long running operation. So Duplex is the ideal choice as I can use call back methods. But my operation returns results at the end of the operations. So what is the recommendation to solve this problem?
Reuest-reply operation and one-way call back method for the progress messaages from the service within the operation?
Blocking (request-reply) operation and blocking (sync) progress messages from service
电话回馈方法是否使用同一渠道,因此,我的封锁(再次提出)方法将产生结果?
- If yes, should I perform my service operation asynchronously.
Will the call back method will come in another worker thread or will be returned to the same thread which has given the instance context?
我认为,阻碍服务运作和阻碍发出进步信息(如果能够回到另一个路面)的回击方法将是理想和容易的解决办法。
But I am not sure how much WCF provides me out of box.
换言之,我想做的是与以下法典相似的东西(可能)。 它的工作。 你们是否看到任何问题? (设想是在阻挡性呼吁中采用一种回击方法。) 服务方式多种多样。 因此,我宣布放弃使用SynchronizationContext=虚假),以避免僵局。 是否有任何问题采用以下办法?
[ServiceContract(CallbackContract(typeof(IServiceCallback)]]
public interfact IService
{
//A long (timetaken) request-reply operation
string LonggggWork();
}
public interface IServiceCallback
{
void Report(string msg);
}
[CallbackBehavior(ConcuerencyMode.Multiple, UseSynchronizationContext=false)]
public ClientCallback : IServiceCallback
{
public void Report(string msg)
{
Console.WriteLine(msg);
}
}
[ServiceBehavior(ConcurencyMode.Multiple, InstanceMode.PerSession)]
publci Service : IService
{
IServiceCallback callback = ....;
public string LongggWork()
{
callback.Report("task1");
task1();
callback.Report("task2");
task2();
...
...
}
}
Eventhough if i set it UseSynchronizationContext to true, WCF is invoking the report method in worker thread itself. So looks like I dont need to set it to false. Will it make sense only for UI thread becasue I am invoking operation already in a another thread?