[問題] 一個windows form小問題 很急
using System.Linq;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.Text;
namespace p2p1
{
public partial class Form1 : Form
{
private const int listenPort = 11000;
public Form1()
{
InitializeComponent();
UDPListener();
}
public void UDPListener()
{
bool done = false;
UdpClient listener = new UdpClient(listenPort);
IPEndPoint groupEP = new IPEndPoint(IPAddress.Any, listenPort);
try
{
while (!done)
{
label1.Text = "Waiting for broadcast";
byte[] bytes = listener.Receive(ref groupEP);
label2.Text = "Received broadcast from "+ groupEP.ToString()+":\n"+Encoding.ASCII.GetString(bytes, 0, bytes.Length);
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
finally
{
listener.Close();
}
}
}
}
byte[] bytes = listener.Receive(ref groupEP);這一行
想請問一下,為啥上面這一行為讓windows form 編譯後開不起來?
程式沒有錯誤,
這段程式再主控台應用程式裡可以編譯開啟,
但到windows form上,編譯過後就沒出現windows form,
有人可以回答我這問題嗎,並且如何解決?? 謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.229.84.246