Appframe Knowledge Base

1 hits

Windows client progress indicator

In old times to indicate something is being loaded one could use CR3.SetStatus(String, Boolean, Boolean) and CR3.ClearStatus() to remove indicator. Those do not work well with asynchronous paradigm. That is why ClientExtensions.AddStatus(Task, String) and afForm.SetIsLoading(Object, Boolean) have been introduced. AddStatus can be used directly on task because it is extension method.

Adding progress indication when refreshing data object:

Await stbv_WinClient_ProjectsVersions.RefreshDataSourceAsync.AddStatus(CR3.TaskType.Data)

The result:

loading indicator

    loading indicator invoked with AddStatus

Similarly one can await result from task, adding progress indication at the same time:

Dim sp = New afProcedureCall("sstp_WinClient_WhatsUp")
Dim dataSet = Await sp.ExecuteAsync.AddStatus("What is up ...")

The result:

loding indicator

    loading indicator invoked for stored procedure execution

Former example does not spin loading indicator in the MDI form tab. How come refreshing data object did spin it?..

That is because refreshing any afDataObject will spin that loading indicator automatically.

To spin it by your self you have to use afForm.SetIsLoading.

Dim t = Task.Delay(3000).AddStatus("аккордеон ...")
SetIsLoading(t, True)
    Await t
    SetIsLoading(t, False)
End Try

The result after calling above code 3 times slightly one after another:

loading indicator

    loading and spining indicator invoked for delay task

When using SetIsLoading be sure to call SetIsLoading(t, False) in Finally block. That way it is going to be called no matter what happens in Try block.

AddStatus and CR3.SetStatus do not interact with each other, so CR3.ClearStatus will not affect any loading indicators invoked using other means.

progress win · Perma link post comment Posted by: Tomas Dambrauskas (26-feb-2016)

Vadim Narožnij :
Moving GIFs in the middle of a text are horrible, looks like a boiling soup. It distracts from reading. Also names like "Formidigus, Uogenojus and аккордеон" are not funny - they are confusing. Please try to keep texts also in examples in English. (24-mar-2016)