Results 1 to 3 of 3

Thread: secondary thread

  1. #1

    Thread Starter
    Banned
    Join Date
    May 2016
    Posts
    1

    secondary thread

    What should I do for my wpf grid to receive and handle data although notifications arrive from a secondary thread.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: secondary thread

    Any changes to the grid will need to occur on the UI thread. Follow the CodeBank link in my signature below and check out my thread on Accessing Controls From Worker Threads. It was originally posted with Windows Forms in mind but there is a post later on that provides a WPF implementation of the same thing. You can use that if your code is in a Window. If it's not then you can use the SynchronizationContext example provided in that same thread.

  3. #3
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,020

    Re: secondary thread

    See article below as reference. The code snippet utilized a TextBlock control. Same concept can be applied to a WPF DataGrid.

    Accessing WPF controls on a non UI Thread
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width