So this is probably another newbie question, but i cant seem to solve it by my own.
I wanted to have a seperate class for the thread where i want to constantly update the integer Distance. The Problem is I get 2 errors:
- The access for ObjectAvoidance.Program.distance_us3 is denied because of the securitylevel.
- c# object reference is required for the non-static field method or property ObjectAvoidance.Program.distance_us3
I have this so far:
using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Presentation.Shapes;
using Microsoft.SPOT.Touch;
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
namespace ObjectAvoidance
{
public partial class Program
{
void ProgramStarted()
{
Thread joystickThread = new Thread(ObjectAvoidance.DistanceReadThread);
joystickThread.Start();
}
}
public class ObjectAvoidance
{
public static void DistanceReadThread()
{
while (true)
{
int Distance = Program.distance_US3.GetDistanceInCentimeters();
}
}
}
}