Author Topic: Datasubscriber2 SynchronizingObject Property  (Read 659 times)

Biker

  • Newbie
  • *
  • Posts: 2
    • View Profile
Datasubscriber2 SynchronizingObject Property
« on: July 10, 2018, 09:09:27 AM »
Hi, I am using the DataSubscriber2 component for the 1st time in a test project, can anyone put a little light on the purpose of the "SynchronizingObject" Property and does it always have to point to an instance of a form?

Any help greatly appreciated.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5267
    • View Profile
    • AdvancedHMI
Re: Datasubscriber2 SynchronizingObject Property
« Reply #1 on: July 10, 2018, 11:32:36 AM »
In a WinForms application all of the graphical interface controls run on a single thread. If you attempt to change something such as the text of a label from a background thread, the application will throw a cross thread operation exception. The DataSubscriber uses the subscription service of the communication driver which runs on a background thread and returns data on that thread. The SynchronizingObject gives a reference to a GUI object in order to access the UI thread and invoke the code execution on that thread. This allows you to change things on the GUI without having to deal with invoking code.

Biker

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Datasubscriber2 SynchronizingObject Property
« Reply #2 on: July 10, 2018, 12:51:24 PM »
Thanks Archie, one more question,

Can the SynchronizingObject be a custom POCO class? or any object?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5267
    • View Profile
    • AdvancedHMI
Re: Datasubscriber2 SynchronizingObject Property
« Reply #3 on: July 10, 2018, 03:18:27 PM »
The Invoke method of the Control class is used to put the executing code on the UI thread. At bare minimum it has to be a Control or inherit from it.