This method allows you to call any .NET async
method - any method that returns a Task
object basically - asynchronously by passing in a callback object that is called back when the async method completes or fails.
o.wwDotNetBridge.InvokeTaskMethodAsync(loCallback, loInstance, loMethod)
Parameters
loCallback
A callback object that implements OnCompleted()
and OnError()
methods that are called when the async method call completes or fails.
loInstance
The object on which the async method is called
loMethod
The method that is to be called as a string
lvParm1..lvParm10
Up to 10 parameters that can be passed to the method.
Example
do wwDotNetBridge
LOCAL loBridge as wwDotNetBridge
loBridge = CreateObject("wwDotNetBridge","V4")
loClient = loBridge.CreateInstance("System.Net.WebClient")
loCallback = CREATEOBJECT("HttpCallback")
*** execute and returns immediately
loTask = loBridge.InvokeTaskMethodAsync(loCallback, loClient,"DownloadStringTaskAsync","https://west-wind.com")
? loTask && object
? "Done..."
RETURN
DEFINE CLASS HttpCallback as AsyncCallbackEvents
*** Returns the result of the method and the name of the method name
FUNCTION OnCompleted(lvResult,lcMethod)
? "File received. Size: " + TRANSFORM(LEN(lvResult))
? SUBSTR(lvResult,1,1500)
ENDFUNC
* Returns an error message, a .NET Exception and the method name
FUNCTION OnError(lcMessage,loException,lcMethod)
? "Error: " + lcMethod,lcMessage
ENDFUNC
ENDDEFINE
See also:
Class wwDotNetBridge© West Wind Technologies, 2004-2020 • Updated: 06/01/20
Comment or report problem with topic