I think I already know the answer, but wanted to see if anyone has a better way. Here's what I want to do:
My application is a data server that listens for multiple PLC triggers (each is a DINT field of a UDT array in a CompactLogix processor). When a trigger is set, the application will read the rest of the UDT and pass the data on to a SQL Server stored procedure. The returned data is then passed back to the PLC.
I don't need this data to be displayed on a form (except possibly as diagnostic information, but I haven't decided whether I want to implement that yet). My question, then, is how do I, or can I, declare the driver and data subscription in code, not attached to a form? In testing I'm getting exceptions when I set the synchronizing object field to a class rather than a form. I understand why that happens, though.
So here's my current thought on how to do this:
1) Create a form that will be created when the app loads, but stays hidden (i.e. form.Visible = False).
2) Add my driver, controls components, and subscribers to the form in design mode.
3) Comment out the code in the VisibleChanged event so that the subscriptions will be polled even though the form is hidden.
Am I on the right track here? If I do it right, I think I can just make the form visible when the user clicks a "Diagnostics" button, and hide the form instead of close it when I'm done viewing it.
Thanks,
Scott