Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Loop in Dispatch.Invoke Not Updating UI

Loop in Dispatch.Invoke Not Updating UI

Scheduled Pinned Locked Moved WPF
wpfdesigntestingbeta-testing
1 Posts 1 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dominick Marciano
    wrote on last edited by
    #1

    In my application I have a window with a custom look and title bar. The XAML for my window is:

    I would like to be able to blink the title bar under some circumstances from a second thread using a loop. For testing purposes I am using the button to start the thread to blink the title bar between green and red with a half-second delay in between the changes. In the button's click event I create a thread and start it:

    Private Sub Button_Click(sender As Object, e As RoutedEventArgs)
    Try
    Dim thread As New Thread(AddressOf ChangeTitleBarColor)
    thread.Start()
    Catch ex As Exception
    Dim m As String = ex.Message
    End Try
    End Sub

    I've only used the Dispatcher a couple of times, so to initially test the ChagneTitleBarColor method and ensure I was using the Dispatch correct I used the following code:

    Private Sub ChangeTitleBarColor()
        Try
            titlebar.Dispatcher.Invoke(Threading.DispatcherPriority.Render, Sub()
                                                                                titlebar.Background =
    
    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups