C # WCF NetTCPBinding application for blocking

I have a basic application like buddylist, which is a pub / sub deal in WCF. My problem is that one or two calls are long, and this blocks the whole server application (gui updates, etc.).

Here is my code:

[ServiceContract(SessionMode = SessionMode.Required, CallbackContract = typeof(IBuddyListContract))] public interface IBuddyListPubSubContract { [OperationContract] string GetABunchOfDataZipped(String sessionId); // this can take > 20 seconds .... } [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Multiple)] public class BuddyListPubSubContract : IBuddyListPubSubContract { string GetABunchOfDataZipped(String sessionId) { // do some calculations and data retrival return result; } } 

So far I have an idea on how to do this, but is there an easier way?

Idea 1 . GetABunchOfDataZipped (String sessionId) will have a void when it has another endpoint that is on my duplex contract that I hit. I don't like this, as if this is a fundamental change in my architecture, and if the line is a large block of text over a slow Internet connection, will it still suffer from the same problem?

+6
source share
1 answer

My problem is that one or two calls are long, and this blocks the whole server application (gui updates, etc.).

You don't know where you see the lock behavior, but it looks like it will be on the client side. You must make your call to your WCF service from a background thread, not from a user interface thread. Then, when you process the result, you cannot directly interact with your user interface elements, you will need to use each Invoke control method.

+2
source

Source: https://habr.com/ru/post/889484/


All Articles