I have a Windows service set up to manage custom .Net tasks. Organization is:
-Windows Service monitors a schedule and starts a worker .exe as needed.
-Worker .
Per last note, pulling the form bit out of it all together appears to have fixed the issue. At this point I'm assuming that server 2012 doesn't like something about a winform app not being displayed in certain situations; since it worked most of the time and nothing had changed in the form's code.
Service:
// Create a temp folder and copy the executable to it
// (so the source exe isn't always in use and can be swapped out)
Process p = new Process();
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = Path.Combine(temp.Path, Path.GetFileName(ExecutablePath));
psi.Arguments = CommandLineArgs.ConcatenateList(" ");
psi.UseShellExecute = false;
psi.RedirectStandardError = true;
psi.RedirectStandardInput = true;
psi.RedirectStandardOutput = true;
psi.CreateNoWindow = true;
psi.ErrorDialog = false;
psi.WindowStyle = ProcessWindowStyle.Hidden;
p.StartInfo = psi;
p.Start();
// read standard output if necessary, kill and reschedule if appears to be frozen, etc.
Worker:
static class Program
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new AppContext());
}
}
class AppContext : ApplicationContext
{
public AppContext()
{
// Do Stuff
}
}