有人可以解决我遇到的问题吗?
我正在研究一个wpf项目.方案如下:
我需要在主UI线程上弹出一个窗口(模型窗口),然后关闭它.这些工作是从另一个UI线程开始的(阻止用户点击主UI窗口.)然后我关闭这个窗口.主要代码如下所示.它有效.
据我所知,close方法在ShowDialog()返回之前不会被执行(至少在UI线程上是这种情况,我的意思是没有调度程序的代码),有没有人有多线程的经验?
Window window;
private void Button_Click(object sender, RoutedEventArgs e)
{
Thread thread = new Thread(() =>
{
//create a window and let user work from this thread
//code is omitted.
//create another window on main UI thread
Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{
window = new Window();
window.ShowDialog();
}));
//do some work here
Thread.Sleep(1000);
Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{
//Thread.Sleep(1000);
window.Close();
}));
});
thread.Start();
}
Run Code Online (Sandbox Code Playgroud)
感谢您的时间!
我正在使用Inno Setup安装程序,该安装程序调用net use连接到共享服务器.安装程序可以连接到服务器,如果它在Windows XP上运行,但不在Windows 7上运行.我认为它与UAC有关,因为我输入相同的命令,服务器在Windows 7上连接,但安装程序正在运行,具有admin特权.
我正在使用以下net use命令Exec或ShellExec脚本函数:
/c net use \\servername password /user:username
Run Code Online (Sandbox Code Playgroud)
实际上,这是显示net use命令调用的脚本的一部分:
[Code]
var
ErrorCode: Integer;
cmdString: String;
intvalue: Integer;
str: String;
function InitializeSetup(): Boolean;
begin
cmdString := '/c net use \\servername password /USER:username';
ShellExec('', ExpandConstant('{cmd}'), cmdString , '', SW_SHOWNORMAL,
ewWaitUntilTerminated, ErrorCode)
if (ErrorCode = 0) then
begin
MsgBox(ExpandConstant('{cmd}'), mbInformation, MB_OK);
end;
end;
Run Code Online (Sandbox Code Playgroud)
任何人都可以建议如何使用net useWindows 7上的Inno Setup?我们只想连接到服务器并让用户输入名称和密码.
谢谢!