Invoking a WCF service without blocking the front UI
We can consume WCF services from various client applications and, in most cases, the WCF client consumer is a GUI application that needs to respond to front UI interactions as well as any background processing tasks. In such cases, if we need to call a long-running WCF service operation, it is important to make sure that the service invoking won't block the front UI interaction.
In this recipe, we will use a typical WinForm client application to demonstrate how we can consume a WCF service in GUI applications without impacting the front UI interaction.
How to do it...
WCF supports several means to achieve service operation invoking without blocking the front UI actions. Here we will introduce two methods to achieve this. The following screenshot shows the main window of the sample WinForm application.
Call the service operation in the normal synchronous way.
The client form contains three buttons, each of which demonstrates a service-invoking...