views:

63

answers:

1

Hello all,

I am doing some refactoring on a piece of code to transform all blocking operations to their async counterparts. My code is in C# and is doing an UPnP query followed by an HTTP query. For this, I use the APM methods of UdpClient and WebClient (BeginReceive, and so on).

My single method is now a succession of Call_1 -> Callback_1 -> Call_2 -> Callback_2 and so forth.

Can somebody point me to some guidelines on the names that should be given to methods in that situation, knowing that everything except Call_1 is not part of my class interface. The methods Callback_1, Call_2, etc. are in fact just a side-effect of desynchronizing the workflow. What nomenclature would you use?

Using CCR, everything would stay in a single pretty method using the yield keyword, but unfortunately, I won't use CCR for now.

A: 

To express to client code what the intention of your code is, i would prefix all methods that have async behaviour with run. Eg: runSOQuery, runDiskCheck and so on.

Maybe stupid but even clearer to client code could be fireAndForget, but not sure if I understood your question correctly...

Best could be to express the async semantics of the method by returning a special return value, like a java.util.concurrent.Future, in the case of Java or something "home made", elsewhere. .

raoulsson