jueves, 20 de septiembre de 2012

DoEvents in WPF vb.net

If you need to refresh the screen after a task has been accomplished, this method is easy to implement: (Si necesita actualizar la pantalla luego de que una tarea fue ejecutada, este es un método fácil de hacerlo)

Public Shared Sub DoEvents(ByVal dispatch As Dispatcher)
dispatch.Invoke(New Action(AddressOf DoEventsHandler), DispatcherPriority.Background)
End Sub
 
Private Shared Sub DoEventsHandler()
End Sub

 to call this Method you can use:

label1.text="Starting process"
DoEvents(Application.Current.Dispatcher)

'Big process starting here
.
.
label1.text="Second process"
DoEvents(Application.Current.Dispatcher)
'Second Big process starts
.
.



Based on http://www.toove.com/archives/70

No hay comentarios: