neo-sharp
neo-sharp copied to clipboard
Remove Delay usage from BlockProcessor
In the name of clean and good code we should find a solution where we don't need to use the Task.Delay that drain the resources like CPU and energy.
Maybe it's possible to create a class that implement the observable pattern like the ObservableCollection but in our case a "ConcurrentObservableCollection" (something like this) where an event is fired when something is added to the list.
Found this threads in StackOverlow
- https://stackoverflow.com/questions/3899940/is-there-a-threadsafe-observable-collection-in-net-4
- https://stackoverflow.com/questions/23108045/how-to-make-observablecollection-thread-safe
where someone said that implement a version of the Observable Collection using ReaderWriteLockSlim https://pastebin.com/hKQi6EHD
this is an example from the Microsoft site using too the ReaderWriteLockSlim https://docs.microsoft.com/en-us/dotnet/api/system.threading.readerwriterlockslim?view=netframework-4.7.2