You are viewing our Forum Archives. To view or take place in current topics click here.
#11. Posted:
Crimson-Mods
  • New Member
Status: Offline
Joined: Jun 24, 201410Year Member
Posts: 39
Reputation Power: 1
Status: Offline
Joined: Jun 24, 201410Year Member
Posts: 39
Reputation Power: 1
Mildot wrote You are turning it on then right back off.. Here try this:
if(Jtag.activeConnection)
{
   if(!cyclestate)
   {
      cycleThread = new System.Threading.Thread(new System.Threading.ThreadStart(VoidDownthere));
   cycleState = true;
   cycleThread.Start();
   }
   else
   {
      cycleState = false;
      cycleThread.Abort();
   }
}


Thats not my problem its something in the code but when i dont use thay cycle method it works fine
#12. Posted:
Mildot
  • Resident Elite
Status: Offline
Joined: Dec 25, 201310Year Member
Posts: 248
Reputation Power: 10
Status: Offline
Joined: Dec 25, 201310Year Member
Posts: 248
Reputation Power: 10
You need the else statement because your statement is pretty much:
if(Jtag.activeConnection)
{
      cycleState = false;
      cycleThread.Abort();
}


it should be:

if(Jtag.activeConnection)
{
   if(!cyclestate)
   {
      cycleThread = new System.Threading.Thread(new System.Threading.ThreadStart(VoidDownthere));
      cycleState = true;
      cycleThread.Start();
   }
   else
   {
      cycleState = false;
      cycleThread.Abort();
   }
}
#13. Posted:
Crimson-Mods
  • New Member
Status: Offline
Joined: Jun 24, 201410Year Member
Posts: 39
Reputation Power: 1
Status: Offline
Joined: Jun 24, 201410Year Member
Posts: 39
Reputation Power: 1
Mildot wrote You need the else statement because your statement is pretty much:
if(Jtag.activeConnection)
{
      cycleState = false;
      cycleThread.Abort();
}


it should be:

if(Jtag.activeConnection)
{
   if(!cyclestate)
   {
      cycleThread = new System.Threading.Thread(new System.Threading.ThreadStart(VoidDownthere));
      cycleState = true;
      cycleThread.Start();
   }
   else
   {
      cycleState = false;
      cycleThread.Abort();
   }
}


I tried that but thats still not my error i just think that it cant handle the code
#14. Posted:
Mildot
  • Resident Elite
Status: Offline
Joined: Dec 25, 201310Year Member
Posts: 248
Reputation Power: 10
Status: Offline
Joined: Dec 25, 201310Year Member
Posts: 248
Reputation Power: 10
Here is what I do for creating a infinite loop that I can stop and start:

All you need is a Switch Button.


public void cycle()
{
   for(;;)
   {
     //whatever you want in here!
     //then this:
     if(switchButton1.Value == (false))
     {
         break;
     }
   }
}

//here is my switch statement:
private void switchButton1_ValueChanged(object sender, EventArgs e)
        {
            switch (switchButton1.Value)
            {
                case false:
                new System.Threading.Thread(new System.Threading.ThreadStart(this.cycle)).Abort();
                break;
                case true:
                new System.Threading.Thread(new System.Threading.ThreadStart(this.cycle)).Start();
                break;

Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.