Solved

WPF Dispatcher

Posted on 2010-11-19
2
389 Views
Last Modified: 2012-05-10
Hi
I need som help with this code.

How do I write the Dispatcher for this listbox I have?
private void StatusUpdates(string message)

        {

            if (this.uxStatusUpdate.Dispatcher.Thread == Thread.CurrentThread)

            {

                this.uxStatusUpdate.Items.Add(message);

            }

            else

            {

                this.uxStatusUpdate.Dispatcher.BeginInvoke ????            

            }

        }

Open in new window

0
Comment
Question by:AWestEng
2 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 34177721
Here's one way:
*Note the delegate I declared above StatusUpdates()!
private delegate void StatusUpdatesDelegate(string message);



        private void StatusUpdates(string message)

        {

            if (this.uxStatusUpdate.Dispatcher.Thread == Thread.CurrentThread)

            {

                this.uxStatusUpdate.Items.Add(message);

            }

            else

            {

                this.uxStatusUpdate.Dispatcher.BeginInvoke(new StatusUpdatesDelegate(StatusUpdates), new Object[] { message });

            }

        }

Open in new window

0
 
LVL 1

Author Closing Comment

by:AWestEng
ID: 34179207
thx man
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now