private void timer1_Tick(object sender, EventArgs e) { if (_container == null || _environment == null || _environment.NoAgents == 0) { return; } try { listBoxAgents.Items.Clear(); foreach (string a in _environment.AllAgents()) { listBoxAgents.Items.Add(a); } } catch (Exception ex) { richTextBoxLog.AppendText($"Exception: {ex.Message}.\r\n"); richTextBoxLog.Focus(); Application.DoEvents(); } }