[英]ASPX Loading Page
So I'm learning to develop .aspx websites on Visual Studios 2013 and wanted to find out if there was a way to create a "Loading screen" while I executed an executable? 因此,我正在学习在Visual Studios 2013上开发.aspx网站,并想了解执行可执行文件时是否可以创建“加载屏幕”?
The idea is the user pushes a generate button, it runs the executable and displays another page/Pop up window/etc. 这个想法是用户按下“生成”按钮,它运行可执行文件并显示另一个页面/弹出窗口/等。 that will have a loading image and some text until the executable finishes.
在可执行文件完成之前,它将具有加载图像和一些文本。 Then I want it to redirect to another page.
然后,我希望它重定向到另一个页面。
Whats the best way to make this happen? 做到这一点的最佳方法是什么?
Code examples are always a plus! 代码示例永远是加号! thanks
谢谢
From a high-level perspective: 从高级角度看:
.exe
you want to run and wait for the results) .exe
) <meta http-equiv="refresh" />
that causes the page to reload itself every 10 seconds or so, or kick-off a Comet request to the server to receive notification that the child process completed. <meta http-equiv="refresh" />
,这会导致页面每10秒左右重新加载一次自身,或者向服务器发起Comet请求以接收有关该子项的通知处理完成。 Something like this: 像这样:
// Note these fields are static so they persist between page-loads
private static Dictionary<Int32,Boolean> _processes = new Dictionary<Int32,Boolean>();
private static Int32 _processNum;
ActionResult StartBackgroundTask() {
Int32 num = _processNum++;
_processes.Add( num, false );
Thread thread = new Thread( delegate() {
Process proc = new Process("MyExe.exe");
proc.Start();
proc.WaitForExit();
_processes[ num ] = true; // marking as complete
} );
thread.Start();
return View("BackgroundTaskIsRunning.aspx", num);
}
ActionResult GetBackgroundTaskState(Int32 num) {
// Token `num` received from client.
if( _processes[ num ] ) {
return View("NextTask.aspx");
} else {
// Same view as before
return View("BackgroundTaskIsRunning.aspx", num);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.