asynchronous loops

This is where you talk about Macros, show examples of your macro scripting and SHARE handy segments of script code as examples.

asynchronous loops

Postby Mindustrys » Fri Jul 21, 2023 8:03 am

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
Mindustrys
 
Posts: 25
Joined: Sat Aug 21, 2021 3:47 pm

Re: asynchronous loops

Postby Mindustrys » Fri Jul 21, 2023 8:06 am

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");
}
}
}
Mindustrys
 
Posts: 25
Joined: Sat Aug 21, 2021 3:47 pm


Return to Macros

Who is online

Users browsing this forum: No registered users and 4 guests