I need help again. I have a guy at work who is telling everyone that we will not beat his Halo Reach score before he gets 2,000,000 points. I decided to use a Panda II to prove him wrong. The problem that I am having is mscorlib.dll exceptions when I try to debug the program.
The concept is simple:
-
I am starting the game by pressing the ‘A’ button repeatedly for a preset amount of time.
-
After the game starts I (The Panda II) will be pressing the ‘B’ button repeatedly for a preset amount of time. This makes the console think that the user is not away and also serves to bring the Game back to the main menu so the game can be started again.
I would greatly appreciate someone pointing out my errors and giving me any guidance.
Thanks,
Kevin
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.FEZ;
namespace XBox
{
public class Program
{
static bool bButtonState = false;
static bool aButtonState = false;
static bool threadTracker = false;
static TimeSpan atimespan = new TimeSpan(0, 0, 0, 10);
static TimeSpan btimespan = new TimeSpan(0, 0, 0, 15);
static OutputPort aButtonGND = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di11, false);
static OutputPort aButtonOut = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di10, !aButtonState);
static OutputPort bButtonGND = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di13, false);
static OutputPort bButtonOut = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di12, !bButtonState);
public static void Main()
{
Thread aButtonThread = new Thread(aButtonTimer);
Thread bButtonThread = new Thread(bButtonTimer);
while (true)
{
if (threadTracker == false)
{
bButtonThread.Abort();
if (aButtonThread.IsAlive == true)
{
}
else
{
aButtonThread.Start();
}
}
if (threadTracker == true)
{
aButtonThread.Abort();
if (bButtonThread.IsAlive == true)
{
}
else
{
bButtonThread.Start();
}
}
}
}
public static void aButtonTimer()
{
DateTime now = DateTime.Now;
DateTime FinishTime = now.Add(atimespan);
do
{
Timer aTimer = new Timer(new TimerCallback(aButton), null, 500, 3000);
}
while (DateTime.Now < FinishTime);
threadTracker = true;
}
public static void bButtonTimer()
{
DateTime now = DateTime.Now;
DateTime FinishTime = now.Add(btimespan);
do
{
Timer bTimer = new Timer(new TimerCallback(bButton), null, 500, 3000);
}
while (DateTime.Now < FinishTime);
threadTracker = false;
}
public static void aButton(object o)
{
aButtonState = !aButtonState;
}
public static void bButton(object o)
{
bButtonState = !bButtonState;
}
}
}