¿Dónde puedo encontrar un control que sea como el Control de temporizador C # en WPF?
177
El temporizador WPF habitual es el DispatcherTimer, que no es un control pero se usa en código. Básicamente funciona de la misma manera que el temporizador WinForms:
System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
dispatcherTimer.Tick += dispatcherTimer_Tick;
dispatcherTimer.Interval = new TimeSpan(0,0,1);
dispatcherTimer.Start();
private void dispatcherTimer_Tick(object sender, EventArgs e)
{
// code goes here
}
Puede encontrar más información sobre DispatcherTimer aquí
var timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) };Con Dispatcher deberás incluir
También tenga en cuenta que si hace clic con el botón derecho en DispatcherTimer y hace clic en Resolver, debería agregar las referencias apropiadas.
fuente
también puedes usar
fuente
El temporizador tiene funciones especiales.
si usa
StartAsync ()oStart (), el hilo no bloquea el elemento de la interfaz de usuariofuente