Let's be strict here. Your code snippet doesn't actually get any event frames. It merely creates an instance of AFEventFrameSearch object. The actually getting of event frames does not occur until you issue a prevENDEFSearch.FindEventFrames() call. And that call doesn't necessarily return all frames but rather a series of pages of event frames. Granted if you keep asking for the next event frame when you're at the bottom of a page, then a new page will fetched.
Therefore I think what you are wanting to do is to limit the pageSize with the FindEventFrames call, and then exit any loop after you've found the first one.
Also some general tips:
- You want to enable server-side caching.
- You want to use CaptureValues() on any closed event frames.
OK, so it would be enough with setting the page size to 1 and getting only the first EF. Thanks!
You might also want read this: https://pisquare.osisoft.com/message/96484-re-afeventframesearch-and-paging#comment-96484
I believe prevENDEFSearch.FindEventFrames(0, true, 1); will get you there and you can just stop iterating after you have your first EF.