I want to fill the list with more data while the code is running but the window is unresponsive. It worked in MVC application.
private void button1_Click(object sender, EventArgs e)
{
List<string> list = new List<string>();
list.Add(textBox1.Text);
bool pingable = false;
Ping pinger = new Ping();
try
{
PingReply reply = pinger.Send(textBox1.Text);
pingable = reply.Status == IPStatus.Success;
}
catch (PingException)
{
// Discard PingExceptions and return false;
}
while (pingable == false)
{
try
{
PingReply reply = pinger.Send(textBox1.Text);
pingable = reply.Status == IPStatus.Success;
}
catch (PingException)
{
// Discard PingExceptions and return false;
}
Thread.Sleep(1000 * 60 * 30);
}
{
try
{
var mailMsg = new MailMessage();
// To
mailMsg.To.Add(new MailAddress(textBox2.Text));
// From
ect ect
I want to fill out the List with new PC names as the App runs. then i will add a for cycle to do ping for every PC and do pause after emails to the PCs that are online are sent. What am I doing wrong? Or you can't interact with app when event is running?