Author Topic: Code To Run All Of The Time  (Read 787 times)

Phrog30

  • Guest
Code To Run All Of The Time
« on: August 01, 2016, 11:08:29 PM »
I'm sure this is a very basic question, but what is the preferred method to execute something all of the time, no matter what form is open?  Example, if I have code that looks at the PLC for a condition then logs to SQL/mySQL database.  I don't want to have this on all forms, and I really don't like putting code in headers or footers (nav bars), but curious as the best course of action.

Thanks,
James

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: Code To Run All Of The Time
« Reply #1 on: August 02, 2016, 09:48:16 PM »
I'm not sure if this will work but you can try these 2 possible ways:

1) Use MainForm and comment out the code to stop polling when the form is not visible. You might need to add code to the procedure that does logging to continue doing so even when the form is not visible (maybe BackgroundWorker might do the logging or possible use of async await - Archie would probably know more about these than I currently do).

2) Create an independent project that does exactly what you want and have it running all by itself.
« Last Edit: August 02, 2016, 11:15:16 PM by Godra »