XK
Implementing a Service that caches requests and then executes on an interval.
Any examples I could look at for something like this?
I have some objects that when they are created need to refresh some data from a service endpoint that has strict requests per minute. However I can batch a set of objects and request data for many of them only using one request.
If I have a service
bool IUpdateService.IsObjectRegistered(string objectId)
and I wanted to
await concreteService.IsObjectRegistered("12345")
but have that service queue all requests, waiting 5 seconds, batching those requests to the service endpoint, parsing the return data, and then returning the relevant data to the thread, how would I do that?
I have something working right now but it fails some of the time.
My current implementation is using TimedQueue and a ManualResetEvent.
The TimedQueue enqueues objects and then every 5 seconds raises an event to batch the service request and populate a variable. Meanwhile the consumer is waiting with manualResetEvent.WaitOne(), which is set and then immediately reset after the batched service request is completed.
Anyway, any examples of something like this I could look at?22 replies
WPF ListBox w/ Header Button IsEnabled Question
I have a ListBox that displays items in need of approval, the ListBox.ItemTemplate is set to a viewmodel displaying the item's view in the list and each has an individual approve button.
I also have set the GroupStyle.HeaderTemplate to include an 'approve all' button, which I have working by using a behavior that uses the datacontext of the button (CollectionViewGroup) to send an event indicating which of the items should be approved.
My items require being updated from several databases before they are ready for approval, which happens asynchronously and their individual approve buttons enable once they are in a state where approval is valid.
My question is, how would I go about implementing disabling the 'approve all' button in the ListBox HeaderTemplate while the items in the CollectionViewGroup are awaiting their background updates.
I've been able to check them manually at the time of click not perform the action if they aren't all in the proper state but I'd like the UI to indicate they cannot be 'all approved' until the items have all updated to the proper state.
6 replies