Discussion:
Issue with Threads
c***@gmail.com
2018-02-20 13:42:00 UTC
Permalink
Hi am having some major issues while using threading in my robot.

Am using c#

If I create a thread that logs to the console i don't have any issues but
when I try and do anything with my robot i get the error
java.nio.BufferOverflowException

This is the code am using

public override void Run()
{
this.TurnRadarLeft(45);
this.RadarColor = Color.Red;
Robocode.Thread t = new Robocode.Thread(() => MoveRadar());

t.Start(this);
while (true)
{
Move();
}
}


public void MoveRadar()
{
while (true)
{
for (double x = 1; x < 10; x++)
{
TurnRadarRight(9);
}
for (double x = 10; x > 1; x--)
{
TurnRadarRight(9);
}
Robocode.Thread.Sleep(100);
}


}


If i change the TurnRadarRight to a console.writeline it is fine and
doesn't error but ever If I remove the look from the MoveRadar function and
replace it with a simple Fire(1) i get the same error.

And help would be great.

Thanks
--
You received this message because you are subscribed to the Google Groups "robocode" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robocode+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Loading...