我在其他地方尝试过,但没有任何结果。基本上我希望图像显示在图片框中。
我的代码:
Dim ScreenReceiverClient As New TcpClient
Dim ScreenReceiverServer As New TcpListener(ScreenReceiverPort)
Dim ScreenReceiverListening As New Thread(AddressOf ScreenListen)
Dim GetScreen As New Thread(AddressOf ReceiveScreen)
Private Sub ReceiveScreen()
While ScreenReceiverClient.Connected = True
Call New Action(AddressOf ChangeImage).BeginInvoke(Nothing, Nothing)
End While
End Sub
Private Sub ChangeImage()
Dim bf As New BinaryFormatter
PictureBox1.Image = bf.Deserialize(ScreenReceiverClient.GetStream)
End Sub
Private Sub ScreenListen()
While ScreenReceiverClient.Connected = False
ScreenReceiverServer.Start()
ScreenReceiverClient = ScreenReceiverServer.AcceptTcpClient
End While
GetScreen.Start()
End Sub
ChangeImage() 应该在 UI 线程而不是 ScreenReceiverListening 线程上调用,但 UI 只是冻结。请帮我!