oregon ha scritto:
Non ho capito che intendi.
I servizi usano un thread creato nella onstart ed eventuali altri thread creati all'interno del primo se necessari. A te basta il primo che esegue un loop controllato da uno sleep
Ti ringrazio del tuo aiuto!
Allora ho creato il thread nell'on start
protected override void OnStart(string[] args)
        {
            Thread t = new Thread(new ThreadStart(moveFile));
            t.Start();
            Thread.Sleep(1000);
            WriteToFile("Timer avviato " + DateTime.Now);
            tmr = new System.Timers.Timer();
            tmr.Interval = 1000;
            tmr.Elapsed += new ElapsedEventHandler(tmr_Elapsed);
            tmr.Enabled = true;
        }
Purtroppo deve esserci un errore. Lo sleep va sotto allo start oppure nel metodo che sposta i file? In realtà ho provato entrambi ma non ha funzionato