Firstly, since you need to access the service at the same time when the service processes the first client call (Processing), you need to change the concurrency service mode to several.
You also want to save every client processing status, so you need to set the instance context mode in PerSession.
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode= InstanceContextMode.PerSession)]
Note
- Default InstanceContextMode - PerSession
- By default, ConcurrencyMode is Single
You can do the following to make sure your configuration is compatible with the PerSession InstanceContextMode, using this method, WCF will throw an exception at run time if necessary
[ServiceContract(SessionMode=SessionMode.Required)]
Note With InstanceContextMode.PerSession, you will get a different instance for each proxy created
Thus, you only need one instance of "Service1Client" for each client, which you will call it the Method method, and also get the status from it.
Also, for virtual heavy processing, you can use Thread.Sleep (millisecond) for the test, offered only in the "Processing" (Service-Side) method.
For a client application, if you want to call the "Processing" method, and then using the "Status" method to get the status, you need to call the "Asynchronous" method.
1.Click on the service link in the explorer solution and select "Configure service link", then check "Generate asynchronous operation" and click "OK".
2. Change your client code as follows
static void Main(string[] args) { StartProcessing(); StatusReport(); Console.ReadLine(); } static ServiceClient Client = new ServiceClient(); private static bool Completed = false; public static void StartProcessing() { XmlDocument doc = new XmlDocument(); doc.Load(@"D:\t72CalculateReasonableWithdrawal_Input.xml"); bool error = false; Client.ProcessingCompleted += Client_ProcessingCompleted; Client.ProcessingAsync(doc.OuterXml); Console.WriteLine("Processing..."); } static void Client_ProcessingCompleted(object sender, ProcessingCompletedEventArgs e) {