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?
WCFC#

Avatar of undefined
Last Comment
Bob Learned

8/22/2022 - Mon
Bob Learned

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

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
Bob Learned

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23