Navigation X
ALERT
Click here to register with a few steps and explore all our cool stuff we have to offer!



 4235

[C#] What's the best way to load big combos in a program without it hanging?

by KeCa - 12 June, 2018 - 12:45 PM
This post is by a banned member (KeCa) - Unhide
KeCa  
Registered
12
Posts
3
Threads
6 Years of service
#1
I think title says it all.

I'm currently using a StreamWriter and adding each line to a Hashset, but combos of 1MILL and above, take around 40 seconds to load.

Is there a faster way?
This post is by a banned member (Spaceman) - Unhide
Spaceman  
Registered
116
Posts
3
Threads
6 Years of service
#2
add them to a queue
[Image: 2k2g0Nr.gif]
This post is by a banned member (0x29A) - Unhide
0x29A  
Registered
172
Posts
39
Threads
6 Years of service
#3
(This post was last modified: 12 June, 2018 - 09:27 PM by 0x29A.)
Backgroundworker or load data asynchronous to wherever you want
This post is by a banned member (Dijkstra) - Unhide
Dijkstra  
Registered
2
Posts
0
Threads
6 Years of service
#4
(This post was last modified: 21 June, 2018 - 03:00 PM by Dijkstra.)
There's not need to actually load all the combos in memory at once. Just keep the stream open and read a combo when you need one. Loading 1 million combos will take up a chunk of memory.
This post is by a banned member (Ethan) - Unhide
Ethan  
Registered
958
Posts
120
Threads
6 Years of service
#5
Just load it up in chunks or when you're actually using a chunk.
This post is by a banned member (Edward) - Unhide
Edward  
Registered
344
Posts
162
Threads
6 Years of service
#6
I would use File.ReadAllLines() , i think its the best.
[Image: DARKHOST_2.gif]
This post is by a banned member (0x29A) - Unhide
0x29A  
Registered
172
Posts
39
Threads
6 Years of service
#7
(This post was last modified: 24 June, 2018 - 09:18 PM by 0x29A.)
(22 June, 2018 - 01:16 PM)Edward Wrote: Show More
I would use File.ReadAllLines() , i think its the best.

This will cause your application to freezing and continue working when the list is done (if its alot text it may also crash and stop completely working), its the same like StreamReader. With less text its okay but with such big text like 1 million of lines and this stuff you won't come far with File or StreamReader Class except using it in a backgroundworker.
This post is by a banned member (Deos) - Unhide

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
or
Sign in
Already have an account? Sign in here.


Forum Jump:


Users browsing this thread: 2 Guest(s)