Link to home
Start Free TrialLog in
Avatar of Silas2
Silas2

asked on

int/out params with c#

I'm using an async pattern with c# and wcf. I've got a param I just want to pass straight thru. I've ended up by haveing the param as an in and an out, i.e. twice. Is that the most elegant way of doing it with WCF async?
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

The preferred method is to use a ref or out parameter:

Synchronous and Asynchronous Operations
http://msdn.microsoft.com/en-us/library/ms734701.aspx

[OperationContract(AsyncPattern=true)]
IAsyncResult BeginDoWork(string data, 
                          ref string inout, 
                          AsyncCallback callback, 
                          object state);
int EndDoWork(ref string inout, out string outonly, IAsyncResult result);

Open in new window

Avatar of Silas2
Silas2

ASKER

But you can't use a ref with wcf. I think maybe the data contract approach might be (whilst a bit overkill) preferrable.
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial