On Wed, 14 May 2008 12:36:26 -0700, <gr***********@recursor.netwrote:
If I have a web method called Log() and on the client I call
BeginLog() with a null value for the AsyncCallback, will this cause a
problem? I want to periodically Log messages to a Log web service but
I don't need any return value. Is it poor programming practice to do
it this way? Or is there a more preferred way?
As a general rule, you must call the corresponding "End" method when using
the asynchronous "Begin" method. One notable exception is the
Control.BeginInvoke() method, but that's a very special case.
I don't know the specific answer regarding your Log() method, and your
question sounds a lot more like a web/.ASP question than a more general
C#/.NET question, but I think it's likely that general rule applies here.
Somewhere along the line, you probably should be calling the "End" method.
Note that even if you were to ascertain by inspection that the code
currently doesn't leak anything when you don't call the "End" method,
that's an implementation detail that you should not be relying on. The
standard .NET async API dictates that you should always call the "End"
method.
Pete