Threads and UI under WPF

Hi Experts,

    I have to teach myself WPF in a hurry.  Here are my first very basic but broad questions!

1.   I want to be able to run some tasks in the background at all times (reading info from the serial port).  Where do I even instantiate and start my thread?  There is no more Program.cs...

2.  Once I read the serial port I want to populate a List of classes and have the UI feed off of it and display the info that the background thread read from the serial port.  Under WinForms, I'd just have a global reference to the same instance of my list and have the reader and writter threads lock it up and access it that way.  How would all of this look under WPF?  Just give me a brid's-eye view and I will research the specifics!  I am working with VS2010 and Framework 3.5 but I can up it to 4.0 if I really have to!

Thanks!
axnst2Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vel EousResearch & Development ManagerCommented:
1.  Every WPF application has an App.xaml and MainWindow.xaml control, both of which have corresponding *.cs code behind files.  Unless you are looking to do something a bit more advanced, the general entry point into your WPF application will be the MainWindow.xaml.cs file.

For processing tasks in the background without causing your UI to hang, you either want to look at the WPF Dispatcher ( http://www.switchonthecode.com/tutorials/working-with-the-wpf-dispatcher ) or the BackgroundWorker ( http://www.switchonthecode.com/tutorials/csharp-tutorial-using-the-backgroundworker-class ).

2.  Both the Dispatcher and BackgroundWorker have "work completed" event handlers, that are fired after the "do work" events are completed.  In this event you can make a call to your List<T>.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AngryBinaryCommented:
To add to #1...

Program.cs (or, more specifically, the "main" entry point) still exists, VS just generates that automatically for the WPF project template.

App.xaml.cs defines an Application object. You can override the OnStartup event handler if you need to drop initialization code, or access command line arguments (the event args object "e" will have an Args property.)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.