KeCa

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

Recommended Posts

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?

Share this post


Link to post
Share on other sites

Backgroundworker or load data asynchronous to wherever you want

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Just load it up in chunks or when you're actually using a chunk.

Share this post


Link to post
Share on other sites

I would use File.ReadAllLines() , i think its the best.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Well, depends, if you are using File.ReadAllLines() in a WinForms/WPF application, it will indeed freeze the application till its fully loaded, unless its ran on another thread.

I had once an idea for Progressive Loading, that allowed "loading" any amount of combo, even let's say 10gb, without overflowing the memory at all (like Reading it full does).

Imho its better than loading into chunks because depending on size of combo.

Share this post


Link to post
Share on other sites

Backgroundworker or load data asynchronous to wherever you want

 

I use this method when doing shit which lags out my programs.

 

However the read only if need method should be good too. :hype:

Share this post


Link to post
Share on other sites

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?

 

thank you very much let's try it

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.