[C#] Tales Runner Server

Joined
May 18, 2007
Messages
1,787
Reaction score
291
I'm making a basic Tcp/Udp Server, Which I hope to turn into Tales Runner server emulator. I just started on it today, and I want to get the server re starter working, before I move on.

This is what I have so far.

As you can see, it looks as if it should work. But it doesn't. doesn't even output an error.

PHP:
private void button2_Click(object sender, EventArgs e)
        {
            foreach (Process pi in Process.GetProcesses())
            switch (pi.ProcessName.ToLower())
            {
                case "TcpUdp Server": { }
                    {
                        pi.Kill();
                    }
 
Re: [C#] Tales Server

Code:
private void button2_Click(object sender, EventArgs e)
        {
            foreach (Process pi in Process.GetProcesses())
            switch (pi.ProcessName.ToLower())
            {
                case "TcpUdp Server":
                             pi.Kill();
                             break;
            }
        }

Shouldn't it be like this?
 
Re: [C#] Tales Server

Perhaps the process name isn't right.
You could make a small console program to display all the processes, and see if you did it right.
Code:
            foreach (Process pi in Process.GetProcesses())
            {
                Console.WriteLine(pi.ProcessName);
            }
 
Re: [C#] Tales Server

Yea. I did, and the proccess name is right. But It's ok, I found another way of making one with a console application, and tieing it with the server. If the server goes down it restarts, if the restarter goes down, the server goes down with it.

I used the following code.

PHP:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Threading;

namespace Restarter
{
    class Program
    {
        public static void Main()
        {
            Console.Title = "Server Controler";
            Process p = new Process();
            p.StartInfo.FileName = "TcpUdp Server.exe";
            p.EnableRaisingEvents = true;
            p.Exited += new EventHandler(ProcessDone);
            p.Start();
            p.WaitForExit();
            Console.WriteLine("Server Restarting..");
        }

        public static void ProcessDone(object sender, EventArgs e)
        {
            Console.WriteLine("Server Crash!! Restarting");
            Process p = new Process();
            p.StartInfo.FileName = "TcpUdp Server.exe";
            p.EnableRaisingEvents = true;
            p.Exited += new EventHandler(ProcessDone);
            p.Start();
            p.WaitForExit();
            Console.ReadLine();
        }
    }
}

I put this in the server.

PHP:
public static void Main(String[] argv)
    {
        DoradoTcpUdpServer2 sts = new DoradoTcpUdpServer2();

            Console.Title = "Server Controler";
            Process p = new Process();
            p.StartInfo.FileName = "TcpUdp Server.exe";
            p.EnableRaisingEvents = true;
[B]            p.Kill();[/B]
            p.WaitForExit();
            Console.WriteLine("Killing Server...");
    }

But I need to know if there's another way of doing the p.Kll(); sense that's not a real code and it just crashes the server repeatedly. The part I mean is highlighted.
 
Back