How does it work?
GetLastDataAsync returns Task<something>, which can be used to track the process of an out-going operation. It can get quite complicated. You probably don't need to use async version, unless you have good reason to? You can use powershell jobs for synchronous version, and just poll how the job is doing.
Once I call the async method how can I check if data are available and
recover them?
If you would like to wait for result, you could do GetLastDataAsync(..).Result, but this would be useless, as you can already use the synchronous one.
There is no easy way in my opinion to consume Task correctly. The closest I found was to use some kind of custom DLL, in this manner:
C:\PS> $path = "$home\Pictures\foo.png"
C:\PS> $asyncOp = [Windows.Storage.StorageFile]::GetFileFromPathAsync($path)
C:\PS> Add-Type -Path ~\PoshWinRT.dll
C:\PS> $typeName = 'PoshWinRT.AsyncOperationWrapper[Windows.Storage.StorageFile]'
C:\PS> $wrapper = new-object $typeName -Arg $asyncOp
C:\PS> $file = $wrapper.AwaitResult()
C:\PS> $file
The theory behind wrapper is that it's using Task.Wait behind the scenes, which kind of beats the whole purpose of async. As it's still blocking the main thread.
TLDR; stick with synchronized version & scheduled jobs if you need.
https://rkeithhill.wordpress.com/2013/09/30/calling-winrt-async-methods-from-windows-powershell/
$serviceobject have aGetLastDataCompletedevent as well?