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?
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) <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. 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);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.