//File:Window.xaml.vb Imports System.Windows Imports System.Threading Imports System.ComponentModel Imports System.Windows.Media.Animation Namespace WpfApplication1 Public Partial Class Window1 Inherits Window Private pulseStoryboard As Storyboard Private worker As BackgroundWorker Public Sub New() InitializeComponent() pulseStoryboard = DirectCast(Me.Resources("PulseStoryboard"), Storyboard) pulseStoryboard.RepeatBehavior = RepeatBehavior.Forever worker = New BackgroundWorker() AddHandler worker.DoWork, New DoWorkEventHandler(AddressOf worker_DoWork) AddHandler worker.RunWorkerCompleted, New RunWorkerCompletedEventHandler(AddressOf worker_RunWorkerCompleted) End Sub Private Sub button_Click(sender As Object, e As RoutedEventArgs) pulseStoryboard.Begin(Me, True) worker.RunWorkerAsync() button.IsEnabled = False End Sub Private Sub worker_RunWorkerCompleted(sender As Object, e As RunWorkerCompletedEventArgs) button.IsEnabled = True pulseStoryboard.[Stop](Me) End Sub Private Sub worker_DoWork(sender As Object, e As DoWorkEventArgs) For i As Integer = 1 To 50 Thread.Sleep(100) Next End Sub End Class End Namespace