0
每当handleResponse调用委托函数“func”我的GUI崩溃,没有例外。委托函数将文本附加到GUI上的RichTextBox。C图形用户界面/套接字崩溃的GUI更新
如果我在“连接”中调用this.func,它工作得很好。
private void handleResponse(IAsyncResult result)
{
try
{
this.func.Invoke("test");
}
catch (Exception e)
{
throw e;
}
}
public void connect(string ip, int port, delegateFunction func) {
try
{
connection.Connect(ip, port);
socket = connection.Client;
this.func = func;
socket.BeginReceive(incomingBuffer, 0, incomingBuffer.Length, SocketFlags.None, handleResponse, null);
}
catch (Exception e)
{
throw e;
}
}