Source
..\..\UIRes\ProgressAndAsync.bin
GacUI.h
Demo
module viewmodel; using system::*;

namespace demo { $interface IStringAsync : Async<string>;

interface IViewModel { func BeginDownload(progress:func(int):void, callback:func(string):void) : void;

static func DownloadAsync(viewModel : IViewModel^, progress:func(int):void) : IStringAsync^ { var future = Future::Create(); var promise = future.Promise; viewModel.BeginDownload(progress, func(result : string):void { promise.SendResult(result); }); return new IStringAsync^(using future of Async^); } } }

composeType:MinSize
composeType:Percentage percentage:1.0
composeType:Percentage percentage:1.0
composeType:MinSize
$Async{ buttonDownload.Enabled = false; var text = $Await demo::IViewModel::DownloadAsync(ViewModel, func(progress : int):void { Application::GetApplication().InvokeInMainThreadAndWait(self, func():void { progressBar.Position = progress; }, -1); }); textResult.LoadTextAndClearUndoRedo(text); textResult.SetFocused(); }