4
In my application I have several "subprocesses". They all emit information in which they are displayed in the Form.
I used System.Windows.Forms.Timer:
Class x {
    public Timer timer {get; set;}
    public void f()
    {
        timer = new Timer();
        timer.Tick += new EventHandler(this.tick);
        timer.Enabled = false;
        timer.Interval = 1000;
        timer.Start();
    }
    private async void tick(object sender, EventArgs e)
    {
        this.status = ProcessoStatus.TRABALHANDO;
        this.timer.Stop();
        await Task.Run(() => this.processo());
        this.timer.Start();
        this.status = ProcessoStatus.OCIOSO;
    }
}
One of these subprocesses checks a web service for updated data. But for that I need all other lawsuits to stop.
// main thread
Class Y
{
    public void a()
    {
        X obj1 = new X();
        X obj2 = new X();
        obj1.f();
        obj2.f();
    }
    public sync()
    {
        obj1.timer.Enabled = false;
        while (obj1.status != ProcessoStatus.OCIOSO)
        {
            // faz nada no loop, apenas aguarda o método tick terminar
        }
        obj2.timer.Enabled = false;
        while (obj2.status != ProcessoStatus.OCIOSO)
        { }
        // pega os dados novos do webservice
    }
 }
The problem is that while in many cases hangs the main thread causing the "status" to never be "idle".
Any suggestions to improve this?