Timer on a PSU page to reload a file

Product: PowerShell Universal
Version: 5.2.1

Hello,
I have a PSU page in an app that simply shows a csv file in a table.
I would like to have a timer that checks the file last write time and reloads the file to the table if there was a change.

I already got it going using New-UDEndpointSchedule.
But the Endpoint stays forever.
Calling the page again will have me one more endpoint and so on.
And data exchange from that endpoint is only possible via $cache:.

Is there a way to do this just within the web page?
would work to reload the whole page, but that is disturbing.
I just like to reload the table.

Thanks

I always seem to open a topic, when I am close to find a solution…:wink:

That’s the right approach.

Here the code I put at the begin of the page:

New-UDdynamic -content {
    while ($true) {
        9..0 | %{
            Set-UDElement -id "reload" -Properties @{text="Reload check in $_ seconds"}
            start-sleep 1
        }

        $timestamp=(get-item $page:logs.csvfile).LastWriteTimeUtc.Tostring("yyyy-MM-dd HH:mm.ss") 

        if ($timestamp -ne $page:logs.timestamp) {
            Show-UDToast -Message "Reloading ..."
            $page:logs.csv=import-csv $page:logs.csvfile
            $page:logs.timestamp=(get-item $page:logs.csvfile).LastWriteTimeUtc.Tostring("yyyy-MM-dd HH:mm.ss") 
            $page:logs.data=$page:logs.csv | sort-object datim -Descending
            Set-UDElement -id timestamp -Properties @{value=$page:logs.timestamp}
            Sync-UDElement -id "logstable" #-Wait
        }
    }
}