作者turnps (哇哈哈)
看板C_Sharp
标题[问题] 一个windows form小问题 很急
时间Sat Jan 10 00:39:07 2009
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