-
Notifications
You must be signed in to change notification settings - Fork 2
/
ThreadedDialog.cs
49 lines (46 loc) · 1.76 KB
/
ThreadedDialog.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using SebWindowsClient.ConfigurationUtils;
using SebWindowsClient.DesktopUtils;
using System.Threading;
namespace SebWindowsClient
{
public class ThreadedDialog
{
public static string ShowPasswordDialogForm(string title, string passwordRequestText)
{
if (SEBClientInfo.SebWindowsClientForm != null)
SebWindowsClientMain.SEBToForeground();
if (SebWindowsClientMain.sessionCreateNewDesktop || SEBSettings.settingsCurrent.Count > 0 && (bool) SEBClientInfo.getSebSetting("touchOptimized")["touchOptimized"])
return SebPasswordDialogForm.ShowPasswordDialogForm(title, passwordRequestText);
Worker worker = new Worker();
Thread thread = new Thread(new ThreadStart(worker.ShowPasswordDialogInThread));
worker.dialogTitle = title;
worker.dialogText = passwordRequestText;
thread.Start();
do
;
while (!thread.IsAlive);
thread.Join();
if (SebWindowsClientMain.sessionCreateNewDesktop)
SEBDesktopController.Show(SEBClientInfo.SEBNewlDesktop.DesktopName);
return worker.dialogResultText;
}
public static string ShowFileDialogForExecutable(string fileName)
{
if (SebWindowsClientMain.sessionCreateNewDesktop)
SEBDesktopController.Show(SEBClientInfo.OriginalDesktop.DesktopName);
Worker worker = new Worker();
Thread thread = new Thread(new ThreadStart(worker.ShowFileDialogInThread));
thread.SetApartmentState(ApartmentState.STA);
worker.fileNameExecutable = fileName;
thread.Start();
do
;
while (!thread.IsAlive);
thread.Join();
if (SebWindowsClientMain.sessionCreateNewDesktop)
SEBDesktopController.Show(SEBClientInfo.SEBNewlDesktop.DesktopName);
return worker.fileNameFullPath;
}
}
}