Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • 1
    Will I need to use something like var loadResults = await Task.Run(LoadFilesAsync); to keep the application from locking if I remove the individual Task.Run()'s from LoadFilesAsync? Commented May 1, 2017 at 13:35
  • If LoadFilesAsync() is marked as async then no, you do not. Basically, you want the files to be loaded sequentially since that rarely takes a long time, but you don't want your task to be blocking while the read happens. Commented May 1, 2017 at 13:38
  • 2
    The bigger issue, of course, is that you were calling _file.Clear() in async code, which can be called in parallel. That means your files being loaded might not be as robust as you wanted. Commented May 1, 2017 at 13:40
  • Berin is absolutely correct with regards to MessageBox.ShowMessage usage. In these situations, I like to pass in a logger object of some sort, preferably with log levels (or at least a boolean to indicate something is verbose that can be controlled with a feature flag in configuration) so I can leave in these debug messages yet be able to enable/disable them at will without having to actually change code and without putting in bad-practice code. Commented May 1, 2017 at 13:43