Proper way to use a WCF service RRS feed

  • Question

  • I use  a WCF service in my app and at the moment I create an instance of the client object, exchange some data with the service and keep the object alive for further communication. All the methods are simple request/responses, no sessions or anything. Is this okay or is it preferred to create an instance, call a method and close the object? What I have works fine-ish, but with all the suspending, resuming it happened that the channel was closed when I called the service. So I added a check in the resume code. But I do not know if it's a proper way to do this. I am afraid the overhead can be big to create an object just for one call and throw it away after. So what's a proper/recommended way?
    Saturday, October 5, 2013 4:46 PM


All replies

  • I always create the object, use it, and dispose of it.  
    Saturday, October 5, 2013 5:45 PM
  • Thanks. I use the service as my DB access and it seems like a waste to do it per call. I am going to check if I have to do anything at all when ReceiveTimeout expires and the channel closes.
    Monday, October 7, 2013 6:24 AM