Dispatcher.CheckAccess() isn't working from my console application, is there a better way.

Posted by zimmer62 on Stack Overflow See other posts from Stack Overflow or by zimmer62
Published on 2010-04-21T14:09:11Z Indexed on 2010/04/21 14:23 UTC
Read the original article Hit count: 116

I wrote an application in WPF / VB and separated the business logic and UI into different projects.

The business layer uses a serial port which runs on a different thread, Now that I'm trying to write a command line interface for the same business layer, it seems to fail when .Invoke() is called. (no error, just doesn't work)

I'm pretty sure the reason I had to add in checkaccess and .invoke was because I have collections that would be changed during processing the serial port data and wanted the NotifyCollectionChanged to be handled by WPF data binding. (The reason I'm not 100% sure is because it was months ago I wrote that part and it all worked great from the GUI, now adding the console app has made me rethink some of this)

I would like my business layer to run these processes on the thread they were created, I need this to work from both my GUI version and the command line version.

Am I misusing the Dispatcher in my business layer? Is there a better way to handle an event from the serial port, and then return to the main thread to processes the data?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about multithreading