Stop New-UDDynamic -autorefresh?

Hello, is it possible to stop the autorefresh of a dynamic element ?

Thank you

You might be able to use Set-UDElement.

New-UDDynamic -Id 'test' -Content { } -AutoRefresh 
New-UDButton -Text 'Stop AutoRefresh' -OnClick {
    Set-UDElement -Id 'test' -Properties @{
       autoRefresh = $false
    }
}

Thank you but is there a way to stop it from inside itself ?

You can call Set-UDElement from within the dynamic’s content based on some critieria.

New-UDDynamic -Id 'test' -Content {
     if ($Session:StopRefreshing)
     {
           Set-UDElement -Id 'test' -Properties @{
                  autoRefresh = $false
           }
     }
} -AutoRefresh