Question

The question mainly is in the Read() method.

public static void Read(object source, ElapsedEventArgs e)
{
    serverID = File.ReadAllText(sidname);
    Console.WriteLine("Current ID: " + serverID);
    if (serverID != oldserverID && serverID != "default" && serverID != "")
    {
        ProcessStartInfo servqueued = new ProcessStartInfo();
        servqueued.Arguments = ramlimit + " " + spname + " " + sidname + " " + resourcetxt + " " + ramoutput + " " + rootpath + Path.DirectorySeparatorChar + " " + makeserverpath + " " + Logpath + " " + servqueuepath;
        servqueued.FileName = fileservepath;
        servqueued.WindowStyle = ProcessWindowStyle.Normal;
        servqueued.CreateNoWindow = false;
        Process queue;
        queue = Process.Start(servqueued);
        Console.WriteLine("Server process queued with server name: " + serverID);
        File.AppendAllLines(logpath, new string[] { DateTime.Now.ToString("HH:mm:ss tt") + ": ", "Server process queued with server name " + serverID });
        oldserverID = serverID;
    }
}

Not sure why the Process.Start is ignored. The rest of the clause is fine, such as, if I put the oldserverID in the beginning.

EDIT

The arguments are global variables, and defined earlier in the script.

EDIT

Here are the global variables that are referenced. Mind the path hardcoding.

rootpath = "%USERPROFILE%" + Path.DirectorySeparatorChar +"desktop" + Path.DirectorySeparatorChar + "TerrariaServer" + Path.DirectorySeparatorChar + "filebin";
logpath = rootpath + Path.DirectorySeparatorChar + "fr_log.txt";
servqueuepath = rootpath + Path.DirectorySeparatorChar + "queuecheck.txt";
spname = "serverparams.cmd";
sidname = "serverid.cmd";
resourcetxt = rootpath + Path.DirectorySeparatorChar + "ramcheck.txt";
ramoutput = rootpath + Path.DirectorySeparatorChar + "sysresourceoutput.exe";
makeserverpath = rootpath + Path.DirectorySeparatorChar + "update.bat";
Logpath = rootpath + Path.DirectorySeparatorChar + "fsrv_log.txt";
fileservepath = rootpath + Path.DirectorySeparatorChar + "FileServe.exe";

UPDATE

Through the use of proper debugging methods (below), the problem source was.. solved, title edited.

Était-ce utile?

La solution

Are you sure there isn't a try/catch clause upwards a little bit that could be swallowing an exception?

There is no way Process.Start is just being "Ignored". Code is either not reaching it, or its executing, but just not as you'd expect.

There are a few things I'd suggest, set a breakpoint on the first line of the method, and step through the rest of it and watch what is happening - specifically in the locals/watch window. The other thing, would be to break on completion and use intellisense to look and see if there were any other swallowed exceptions in the framework or in your code.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top