In general, there are two ways to work around the asynchronous processing side effect (returning the old value then processing):
- Use CP input links (as Mark suggested).
- Use FLNK processing.
Both are triggered at the second phase of an asynchronous processing.
Which is more appropriate depends mostly on your application. Aspects to consider:
FLNK processing is immediate (calling the process function of the target) when local, loosely coupled using Channel Access when remote.
FLNKs only transfer control; fetching data will need another Channel Access roundtrip.
With input links, you're getting notified when the connection goes away - output links are fire-and-forget.
CP inputs use monitors and will always get an update when the connection comes up - that's like a late PINI processing for the record with the input link. If a record has many CP inputs, it will process many times after reboot.
Cheers,
~Ralph