-1
我想在代碼運行時用更多的數據填充列表,但窗口沒有響應。它在MVC應用程序中工作。Windows應用程序。在代碼運行時填寫更多數據
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
我想在App運行時用新PC名填寫List。然後我將添加一個for循環爲每臺PC執行ping操作,並在發送到在線PC上的電子郵件後暫停。 我在做什麼錯? 或者當事件正在運行時你無法與應用程序交互?
private async void listBox1_SelectedIndexChanged(object sender,EventArgs e) 像這樣? Tnx –