02-05-2013 01:12 PM
@crossrulz wrote:
Of course, if going Jeff's route, you don't even need the notifier; the data is in the queue.
But not the up-to-date data, or did I overlook something?
02-05-2013 01:39 PM - edited 02-05-2013 01:39 PM
@AStankov wrote:
But not the up-to-date data, or did I overlook something?
Yup, with the mod I made to crossrulz exampleif multiple slider events are fired only one (the first) slider command is allowed in the queue but the notifier data is refreshed so that when slider is processed the latest slider value is applied. It really was an interesting challenge. Of course, you could just keep the slider command filter, and dump the notifier for a (Gasp!) Local variable read in the consumer to achieve the exact same performance!
02-05-2013 01:41 PM
@JÞB wrote:
@AStankov wrote:But not the up-to-date data, or did I overlook something?
Yup, with the mod I made to crossrulz exampleif multiple slider events are fired only one (the first) slider command is allowed in the queue but the notifier data is refreshed so that when slider is processed the latest slider value is applied. It really was an interesting challenge. Of course, you could just keep the slider command filter, and dump the notifier for a (Gasp!) Local variable read in the consumer to achieve the exact same performance!
Or you could not worry about re-loading the queue and just use the notifier's timeout like in my example.
02-05-2013 04:43 PM
It is probably also a question of personal preference. But it is also important to know if only one slider is watched or multiple controls. One would then probably need multiple notifiers.
Also, is speed so important for UI events or is it more important to prevent the queue from filling up with events.
02-06-2013 07:13 AM
Well, after thinking again, now it looks like I am going to solve my problem through a simple FGV with a flag inside. The flag will signal if the FGV has been already read out by the consumer, in that case a new "slider" message can be enqueued, otherwise the slider value will be updated but no enqueue will be performed, because a previous "slider" message is still in the queue and needs to be processed. On the other hand the FGV can be also used to always store the latest slider value or even the values of multiple controls if required. Of course I could also read the slider directly or through a local var inside the consumer, but the FGV inbetween offers additional flexibility, e.g. one could check if a control has been set to an allowed value before the FGV is updated in order to be read by the consumer.
02-06-2013 07:25 AM
That sounds like a really good solution. 1. You avoid the extra enqueueing and messing with the queue. 2. You still keep the latest value. 3. You don't have to keep track of another set of references.
02-06-2013 07:34 AM
@crossrulz wrote:
That sounds like a really good solution. 1. You avoid the extra enqueueing and messing with the queue. 2. You still keep the latest value. 3. You don't have to keep track of another set of references.
Exactly, somehow I forgot to list the main benefits 🙂 Thanks again! BTW crossrulz, I will try to mark your post as the solution to the topic of the thread, as it fits best. Jeff's solution is actually an extension of it.