Async Callback in Web Service
-
When I use the wsdl tool to create a web service proxy, it always makes the call back delegate a module level object variable, it then puts the code in as follows:
private SendOrPostCallback _cb; public void GetProductsAsync(ProductsRequestEntity request, object userState) { if (_cb == null) _cb = new SendOrPostCallback(OnGetProductsCompleted); this.Invoke("GetProducts", new object[] { request}, _cb, userState); }
Does the callback delegate need to be a module level variable, will coding it the following way cause me any problems:public void GetProductsAsync(ProductsRequestEntity request, object userState) { this.Invoke("GetProducts", new object[] { request}, new SendOrPostCallback(OnGetProductsCompleted), userState); }
I have a lot of proxies to create and tidy up, taking a few shortcuts will save me a lot of time. Thanks in advance, Adam