DO wwUtils 			&& Demo only
DO wwDotnetBridge	&& Load dependencies

LOCAL loBridge as wwDotnetBridge
loBridge = GetwwDotnetBridge("V4")

*** Create a built-in .NET class
loHttp = loBridge.CreateInstance("System.Net.WebClient")

*** Create a callback object - object has to be 'global'
*** so it's still around when the callback returns
*** Use Public or attach to long lived object like form or _Screen
PUBLIC loCallback
loCallBack = CREATEOBJECT("HttpCallback")


*** Make the async call - returns immediately
loBridge.InvokeMethodAsync(loCallback, loHttp, ;
                        "DownloadData",;
                        "https://github.com/RickStrahl/HelpBuilderReleases/raw/master/CurrentRelease/HelpBuilderSetup.exe")

? "Download has started... running in background."

RETURN


*** Callback class - AsyncCallbackEvents is Optional
DEFINE CLASS HttpCallback as AsyncCallbackEvents

************************************************************************
*  OnCompleted
****************************************
FUNCTION OnCompleted(lvResult, lcMethod)

? "Http Call completed"
? "Received: " + TRANS(LEN(lvResult),"999,999,999")

*** Write to file to temp folder
STRTOFILE(lvResult,ADDBS(SYS(2023)) + "HelpBuilderSetup.exe")

TRY
	*** Open the Setup file
	DO wwutils
	GoUrl(ADDBS(SYS(2023)) + "HelpBuilderSetup.exe")
CATCH
ENDTRY

ENDFUNC

************************************************************************
*  OnError
****************************************
FUNCTION OnError(lcErrorMessage, loException, lcMethod)
? lcErrorMessage
ENDFUNC

ENDDEFINE