IObservable<Match> IObservableArray = new Regex("(.*):(.*)").Matches(file).OfType<Match>().ToList().ToObservable();
var query = IObservableArray.SelectMany(s => Observable.Start(() => {
//do stuff
}));
Working Code Above's Explanation: The code above uses Observable with Reactive to do a Concurrent Multi-Threading system while retaining s as a Match.
My issue is that it seems to need to load everything into memory before even starting doing //do stuff
since IObservableArray
is a big array of Matches - this takes up a lot of the memory causing it to do a OutOfMemory Exception.
I have been researching for more than a month and all I can find is .Buffer() which if I put it before the .SelectMany() and then foreach Match over the s, im able to load 1000 Matches into memory at a time causing the memory overall to be much better.
But, since I have to resort to using a foreach to go through all 1000 in the buffer at a time, it isnt concurrent - meaning im basically checking 1 after the other.
Is there a way to do similar code below, yet have it Concurrent/Multi-Threaded? (Have at least 150 running concurrently, but don't load all of it to memory, using 1000 at the moment.)
yes I tried using thread.start etc, using them makes it trigger the finished code much earlier since technically it does finish since it had done what it was told which was make them all into a new thread
IObservable<Match> IObservableArray = new Regex("(.*):(.*)").Matches(file).OfType<Match>().ToList().ToObservable();
var query = IObservableArray.Buffer(1000).SelectMany(s => Observable.Start(() => {
//do stuff
}));
query.ObserveOn(ActiveForm).Subscribe(x =>
{
//do finish stuff
});