Calling WCF operation that has no return value asynchronously
I have a long running operation:
void LongRunningOperation(string someValue);
How do 开发者_如何学Ci call it asynchronously (I want a fire and forget mechanism)?
you can set the mode to oneway.
you do not require to call these methods asynchronously. call to the methods returns as soon as they are call if the mode is one way.
use:
[OperationContract(IsOneWay = true)]
attribute to describe your operation contract.
Assuming that you have already configured your proxy to the service, you will need to do the following (in VS):
- Open your project that references the service, then go to service references.
- Right-click the relevant service reference and select 'Configure Service Reference' from the context menu.
- Tick the box that says 'Generate asynchronous operations'
- After your client code regenerates, you will see a method that says
BeginLongRunningOperation
; that's your async method.
精彩评论