TcpClient DataReadAsyncCallback はメイン UI スレッドで実行されますか? 私はそのハンドラーからウィンドウフォームを作成しています。いくつかの呼び出しとウィンドウ表示の後、アプリケーションは.NETから例外なく終了します。
...
ns.BeginRead(client.RxPacket, 0, client.RxPacket.Length, new AsyncCallback(TcpClientDataReadAsyncCallback), client);
...
private void TcpClientDataReadAsyncCallback(IAsyncResult ar)
{
Client client = (Camera)ar.AsyncState;
// read data
// create window form with that data recieved
MyForm form = new MyForm(/*read data passed*/);
form.Show();
}
または、デリゲートを使用して、別のスレッドからの UI アクセスを追跡する必要がありますか?