Need sample fire and forget async call to WCF service

前端 未结 3 494
忘了有多久
忘了有多久 2020-12-08 23:10

On a scheduled interval I need to call a WCF service call another WCF Service asyncronously. Scheduling a call to a WCF service I have worked out.

What I think I ne

3条回答
  •  爱一瞬间的悲伤
    2020-12-08 23:53

    Set the IsOneWay property of the OperationContract attribute to true on the WCF method that you are calling to. This tells WCF that the call only matters for one direction and the client won't hang around for the method to finish executing.

    Even when calling BeginInvoke your client code will still hang-out waiting for the server method to finish executing but it will do it on a threadpool thread.

    [ServiceContract]
    interface IWCFContract
    {
       [OperationContract(IsOneWay = true)]
       void CallMe()
    }
    

    The other way to do what you want is to have the WCF service spin its work off onto a background thread and return immediately.

提交回复
热议问题