EnumerateFiles Blocks UI thread even in Task.Run()
I'm writing an application that needs to validate a user-given directory by searching for specific files in said directory. I'd like to run the validation in the background so the app doesn't freeze up. I've tried a few suggestions and still ended up here asking because it seems EnumerateFiles refuses to run on another thread.
Following is a functional example as a .net8 WPF application.
7 Replies
Cross posted on Stack Exchange https://stackoverflow.com/questions/79521860/enumeratefiles-blocks-ui-thread-even-in-task-run
Stack Overflow
EnumerateFiles Blocks UI thread even in Task.Run()
I'm writing an application that needs to validate a user-given directory by searching for specific files in said directory (in my case DDS files). I'd like to run the validation in the background s...
that definitely looks right
you probably want button_Click to be
async void
so you can await LiveryValidate, but that shouldn't be causing UI lockupsIts odd, I think it looks right too, but it can't be like a .net bug can it?
Also, adding async to button_Click and await to LiveryValidate didn't change, still locks the UI while scanning.
This is a functional example from my main project and all it does is basically show a green message for validation. It seems like such a headache but userfriendliness is my goal. ugh. Any alternative methods to achieve the same goal without blocking the UI thread?
how does the blocking present itself? the window gets that white tint after a while?
entire app becomes unresponsive
@Budzique odd. I'd hop over to #gui.