diff --git a/README b/README
index c95fea5..4e368ef 100644
--- a/README
+++ b/README
@@ -8,8 +8,10 @@ Usage: StayUp [process] -e -i [interval] -t [timeout]
in seconds. Default is 3600.
-t Time to wait for a process to respond before forcing it
to restart, in seconds. Default is 5.
+ -d Time to wait between launches in seconds
+ Default is 0.
-Example: StayUp MyApp.exe -e -i 3600 -t 5
+Example: StayUp MyApp.exe -e -i 3600 -t 5 -d 10
When event log is enabled, information and errors are recorded logged and
viewable in Windows' Event Viewer. Open the Event Viewer and go to
@@ -17,7 +19,7 @@ viewable in Windows' Event Viewer. Open the Event Viewer and go to
-----------------------------------------
-Version 1.1.0.5
+Version 1.1.0.7
-----------------------------------------
diff --git a/StayUp/Program.cs b/StayUp/Program.cs
index 11e6b33..3b71588 100644
--- a/StayUp/Program.cs
+++ b/StayUp/Program.cs
@@ -63,7 +63,7 @@ class Program
///
/// Version number
///
- const string kVersion = "1.1.0.6";
+ const string kVersion = "1.1.0.7";
#endregion
#region Static members
@@ -137,7 +137,17 @@ class Program
/// Flags whether help message has been displayed
///
private static bool sWroteHelpMessage = false;
-
+
+
+ ///
+ /// Delay for relaunch
+ ///
+ private static Timer sRelaunchDelayTimer;
+
+ ///
+ /// Time between launches
+ ///
+ private static int sRelaunchDelay;
#endregion
#region External
@@ -316,7 +326,14 @@ public static void Main( string[] args )
} else {
WriteHelp();
}
-
+ } else if ( args[ i ] == "-d" ) {
+ ++i;
+ double timeout = 0.0;
+ if ( i < args.Length && double.TryParse( args[ i ], out timeout ) ) {
+ sRelaunchDelay = (int) (timeout * 1000.0);
+ } else {
+ WriteHelp();
+ }
} else {
WriteHelp();
}
@@ -331,8 +348,8 @@ public static void Main( string[] args )
Environment.Exit( 1 );
return;
}
- Console.ReadLine();
-
+ while (Console.ReadKey(true).Key != ConsoleKey.Escape) {}
+
}
///
@@ -367,8 +384,10 @@ static void WriteHelp()
Console.WriteLine( " in seconds. Default is 3600." );
Console.WriteLine( " -t Time to wait for a process to respond before forcing it" );
Console.WriteLine( " to restart, in seconds. Default is 5." );
+ Console.WriteLine( " -d Time to wait between launches in seconds");
+ Console.WriteLine( " Default is 0.");
Console.WriteLine( "" );
- Console.WriteLine( "Example: StayUp MyApp.exe -e -i 3600 -t 5" );
+ Console.WriteLine( "Example: StayUp MyApp.exe -e -i 3600 -t 5 -d 5" );
}
}
@@ -408,7 +427,17 @@ private static void ExitHandler( object sender, EventArgs e )
">> Exit time: " + DateTime.Now.ToString() + "\n" +
GetInfoString(), EventLogEntryType.Error );
}
- Launch();
+
+ if (sRelaunchDelay > 0)
+ {
+ Log("Waiting " + sRelaunchDelay/1000 + "s until relaunch.\nPress ESC to quit");
+ TimeSpan delay = TimeSpan.FromMilliseconds((double) sRelaunchDelay);
+ sRelaunchDelayTimer = new Timer(new TimerCallback(RelaunchTimerHandler), null, delay, TimeSpan.FromMilliseconds(-1));
+ }
+ else
+ {
+ Launch();
+ }
}
///
@@ -423,6 +452,15 @@ private static void InfoTimerHandler( object sender )
Log( "Process information:\n" + GetInfoString() );
}
+ ///
+ /// Timer called after relaunch delay has elapsed
+ ///
+ ///
+ private static void RelaunchTimerHandler(object sender)
+ {
+ sRelaunchDelayTimer.Dispose();
+ Launch();
+ }
///
/// Main application callback
///
diff --git a/bin/StayUp.exe b/bin/StayUp.exe
index 9fe38c2..a241d7c 100644
Binary files a/bin/StayUp.exe and b/bin/StayUp.exe differ
diff --git a/bin/launch.bat b/bin/launch.bat
index 25f0a35..f492764 100644
--- a/bin/launch.bat
+++ b/bin/launch.bat
@@ -1 +1 @@
-StayUp CrashTest.exe -e -i 3600 -t 10
\ No newline at end of file
+StayUp CrashTest.exe -e -i 3600 -t 10 -d 5
\ No newline at end of file