vb.net - Normal v Async calls to a service -


i have wcf service reference configured on client application. provides whole series of functions both retrieve , send data web based database. example:

function errorcodesgetall(byval uname string, byval pword string) string 

and

function errorcodesgetallasync(byval uname string, byval pword string) system.threading.tasks.task(of string) 

i know can populate rich text box first function using following code:

 richtextbox1.text = getcountrylist   private function getcountrylist() string     dim svc new servicereference2.ersapiserviceclient     svc.open     dim str string = svc.errorcodesgetall(username, password)     svc.close()     return str end function      

as wcf still new area me i'm wondering how populate same rich text box time using async variant of errorcodesgetall function?

thanks advice or general pointers how async variants best used.

your service expose "completed" event async method, need handle event.

open service, wire event , call async method

   private sub getcodes()           dim svc new servicereference2.ersapiserviceclient         addhandler servicereference2.errorcodesgetallcompleted, addressof errorcodesgetallcompletedhandler         servicereference2.errorcodesgetallasync()         servicereference2.close()      end sub 

handle event. called when service returns. (normally not add "handler" end of method , name same event, thought might distinguish event , handler)

    private sub errorcodesgetallcompletedhandler(byval sender object, byval e servicereference2.errorcodesgetalleventargs)          if not e.result nothing             textbox.text = e.result         end if      end sub 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -