Reputation: 5534
Suppose I have a class similar to this one (with all the necessary WCF attributes):
class JobProducer
{
Job Produce()
{
// Do some work
return new Job(params);
}
}
and a WCF service (I'm not writing all the attributes, but they're there)
class MyService : IService
{
Producer GetProducer()
{
return new Producer();
}
}
and a WCF client:
IService client;
var producer = client.GetProducer();
var job = producer.Produce();
while (job != null)
{
// Process job
job = producer.Produce();
}
Will that kind of design work? are there any drawbacks that I should be aware of?
More specifically, what happens when I invoke the Produce()
method on the Producer
? will WCF route that method invocation to the service and unblock the client thread when the Job
is ready?
I thought about simply returning a Stream
from the service, but I'd like to avoid deserializing the bytes to a concrete class and let the framework do that for me.
Upvotes: 0
Views: 41
Reputation: 6222
The Produce() method on the local instance of the Job class will be executed. Since Produce() is not a Service Endpoint, no server calls will be made. The instance of Job returned from the Service Endpoint is not leased from the server but completely independent, and importantly, not the same Type as that on the Server but a serialization compatible Type.
Upvotes: 1