A preserved archive of the Logical Gamers community forums, 2009-2025. The original threads and posts, served read-only. Registration, posting and private messages are gone for good.

C# Code Being Ran Twice

1k views · started by Kitsune ·
#1
C# Code Being Ran Twice
So i have this code:

static void Main(string[] args)
{
Console.Title = "Dungeon Defenders Mana Hack";
SetUp();
}

static void SetUp()
{
Process[] processes;
processes = Process.GetProcessesByName("DunDefGame");
if (processes.Length > 0)
{
Write(processes);

}
else
{
Console.WriteLine("Could Not Find Game Process, Please Launch Dungeon Defenders.");
Console.WriteLine("Press any key to retry");
Console.WriteLine("\n");
Console.Read();
System.Threading.Thread.Sleep(1000);
SetUp();
}
}


Initially the code runs once as expected.
BUT when i hit a key to run SetUp() again it runs it twice instead of once. (At this point it has ran 3 times, once initially and twice the second time)
#2
well you see the problem is...


its Christmas.
#3
p.s you have it calling setup in the else statement. maybe have a stronger condition to call setup again.
#4
Kingz V wrote:
well you see the problem is...


its Christmas.


No game hacking allowed on Christmas? :P
I'll try making the if statement a bit better, thanks.
#5
only other thing i could think of is your timer working differently then expected, but that's doubtful.