[Sorry that English is not my native language.]
So, I have a UI and 1 worker on another thread, the worker will call the UI to Update() in random frequency,
so there might be a lot of Update() invoked to the UI. But if there are really multple Update(), then only the latest one is meaningful, yet I have no way to skip those in between.
So I want to
-
“detect if there is an Update() ongoing, if yes, just pend 1 more Update()”
-
“check if there is already 1 more Update() pending, then there is no need to pend more”
before the Update()
But I am not sure what’s the best way to do it. I think surely someone has encountered such problem before. Googling just gives me some unrelated result. So I am looking for some patterns or best practices or search terms or advice or suggestion about this.
Thank you very much
Seems like you need a queue of Update requests with a length of one.
Produce UpdateRequests to the queue and discard them if the queue is full… then consume them from another thread that actually does the final update invoke to the main thread.