@@ -13,25 +13,18 @@ public static class EverythingDownloadHelper
13
13
{
14
14
public static async Task < string > PromptDownloadIfNotInstallAsync ( string installedLocation , IPublicAPI api )
15
15
{
16
- if ( installedLocation . FileExists ( ) )
17
- return installedLocation ;
18
-
19
- if ( ! string . IsNullOrEmpty ( installedLocation ) )
16
+ if ( ! string . IsNullOrEmpty ( installedLocation ) && installedLocation . FileExists ( ) )
20
17
return installedLocation ;
21
18
22
19
installedLocation = GetInstalledPath ( ) ;
23
20
24
21
if ( string . IsNullOrEmpty ( installedLocation ) )
25
22
{
26
- // Solves single thread apartment (STA) mode requirement error when using OpenFileDialog
27
- var t = new Thread ( ( ) =>
28
- {
29
- if ( System . Windows . Forms . MessageBox . Show (
23
+ if ( System . Windows . Forms . MessageBox . Show (
30
24
string . Format ( api . GetTranslation ( "flowlauncher_plugin_everything_installing_select" ) , Environment . NewLine ) ,
31
25
api . GetTranslation ( "flowlauncher_plugin_everything_installing_title" ) ,
32
- System . Windows . Forms . MessageBoxButtons . YesNo ) != System . Windows . Forms . DialogResult . Yes )
33
- return ;
34
-
26
+ System . Windows . Forms . MessageBoxButtons . YesNo ) == System . Windows . Forms . DialogResult . Yes )
27
+ {
35
28
var dlg = new System . Windows . Forms . OpenFileDialog
36
29
{
37
30
InitialDirectory = Environment . GetFolderPath ( Environment . SpecialFolder . ProgramFiles )
@@ -40,13 +33,7 @@ public static async Task<string> PromptDownloadIfNotInstallAsync(string installe
40
33
var result = dlg . ShowDialog ( ) ;
41
34
if ( result == System . Windows . Forms . DialogResult . OK && ! string . IsNullOrEmpty ( dlg . FileName ) )
42
35
installedLocation = dlg . FileName ;
43
-
44
- } ) ;
45
-
46
- // Run your code from a thread that joins the STA Thread
47
- t . SetApartmentState ( ApartmentState . STA ) ;
48
- t . Start ( ) ;
49
- t . Join ( ) ;
36
+ }
50
37
}
51
38
52
39
if ( ! string . IsNullOrEmpty ( installedLocation ) )
0 commit comments