I have a thread that calls an object that receives some things from the Internet. When this object is filled with all the necessary information, it triggers an event with the object, all data will be displayed. The event is consumed by the controller that started the thread.
The returned object from the event is added to the collection, which is bound to the graphical interface using the View Model approach.
The problem is that I cannot use CheckAccess with binding ... how can I fix the problem of using Object that was created from another main thread?
The error I get when I add an object to the main thread collection:
This type of CollectionView does not support changes to the SourceCollection from a stream other than the Dispatcher stream.
This is the controller:
public class WebPingerController { private IAllQueriesViewModel queriesViewModel; private PingerConfiguration configuration; private Pinger ping; private Thread threadPing; public WebPingerController(PingerConfiguration configuration, IAllQueriesViewModel queriesViewModel) { this.queriesViewModel = queriesViewModel; this.configuration = configuration; this.ping = new Pinger(configuration.UrlToPing); this.ping.EventPingDone += new delPingerDone(ping_EventPingDone); this.threadPing = new Thread(new ThreadStart(this.ThreadedStart)); } void ping_EventPingDone(object sender, QueryStatisticInformation info) { queriesViewModel.AddQuery(info);
Patrick desjardins
source share