The new C# API
Posted: Mon Dec 12, 2022 9:32 am
I am running some experiments using the new C# API from WinCC OA 3.19 and I am probably misunderstanding some of the ideas behind the new API.
What I am trying to do is set three separate single DP value connects (so not a single multi value connect) using the ObserveDpValueAsync() extensions method on IOaProcessValues. This call returns a IAsyncEnumerable<ObserveSingleDpValueEventArgs>. No problems so far however when I iterate one of the IAsyncEnumerable's the iteration blocks until an actual event (hotlink) occurs on the observed DPE.
Unless I missed something obvious there does not seem to be a way for me to check if any data is present in the IAsyncEnumerable before actually trying to process it to prevent a blocking call.
Now I can start separate threads or tasks to handle each DP connection but that seems very wasteful to me.
What is the preferred way to handle multiple separate DP connects, query connects, events using the new API from a single thread?
Regards,
Jan
What I am trying to do is set three separate single DP value connects (so not a single multi value connect) using the ObserveDpValueAsync() extensions method on IOaProcessValues. This call returns a IAsyncEnumerable<ObserveSingleDpValueEventArgs>. No problems so far however when I iterate one of the IAsyncEnumerable's the iteration blocks until an actual event (hotlink) occurs on the observed DPE.
Unless I missed something obvious there does not seem to be a way for me to check if any data is present in the IAsyncEnumerable before actually trying to process it to prevent a blocking call.
Now I can start separate threads or tasks to handle each DP connection but that seems very wasteful to me.
What is the preferred way to handle multiple separate DP connects, query connects, events using the new API from a single thread?
Regards,
Jan