Page 1 of 1

asynchronous loops

PostPosted: Fri Jul 21, 2023 8:03 am
by Mindustrys
Hello everyone
how can i do two asynchronous loops inside a macro?
Loop 1 = turn an output on and off
Loop 2 = perform movements in G1

thank you very much

Re: asynchronous loops

PostPosted: Fri Jul 21, 2023 8:06 am
by Mindustrys
attualmente ho scritto questo codice, ma non funziona

using System;
using System.Threading;

class Program
{
static void Main()
{
Thread thread1 = new Thread(Loop1);
Thread thread2 = new Thread(Loop2);

thread1.Start();
thread2.Start();
}

static void Loop1()
{
int port = 1;
int pin = 3;

while (true)
{
exec.Setoutpin(port, pin); // Accendi l'output 1
Thread.Sleep(1000); // Attendere 1 secondo
exec.Clroutpin(port, pin); // Spegni l'output 1
Thread.Sleep(1000); // Attendere 1 secondo
}
}

static void Loop2()
{

while (true)
{
exec.Code("G1A360");
exec.AddStatusmessage("finish");
}
}
}