OpenFolderDialog freezes the program
See original GitHub issueHere is a simple example with a OpenFolderDialog which freezes the program. Originally I tried it without the Task.Run() and instead used await for the result but that had the same issue. So I switched to this code after taking a look at https://github.com/AvaloniaUI/Avalonia/issues/1837
public void SelectFolder()
{
var task = Task.Run(() =>
{
var dialog = new OpenFolderDialog()
{
Title = "Select Folder...",
InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
};
var result = dialog.ShowAsync(Application.Current.MainWindow);
if (result == null)
{
return "Canceled";
}
else
{
return "Selected";
}
});
this.statusUpdate = task.GetAwaiter().GetResult();
}
I am running on Win7 with .net core 3.0 (I also tested .net core 2.1)
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Open file dialog freezes the program when I try to use it
I am using visual studio 2017 to create a windows form application, which I am trying to use OpenFileDialog to load an XML...
Read more >File dialog window makes most program on Windows 11 ...
Hi Hogne, I am Dave, I will help you with this. Your Quick access folder is probably corrupt, the best option is to...
Read more >Solved: C# Open File Dialog freezes.
I have a browse button on a C# winform just like I have a thousand times before. However, this time when I click...
Read more >Call to OpenFileDialog or SaveFileDialog hangs or freezes
Today I was debugging a very strange issue when call to OpenFileDialog and SaveFileDialog hanged, froze, never returned…
Read more >Premiere Pro freezes when trying to open windows file dialog
It's like the dialogue box is hidden and premire is just frozen. I've been fighting this for almost a year. I think i'm...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It’s not the dialog freezing the program, it’s
task.GetAwaiter().GetResult();
causing a deadlock. Use async/await. For more details see TAP.docx.For anyone that was like me trying to do this in a non-async method if you put it in a async method then you can just use ShowAsync without needing to do anything else.