[英]Regarding Windows-universal-samples of Microsoft
Could any one tell me this code 1 , is this function runs every time when it gets a new video frame, if yes then I made a thread after line 188 which basically make a TCP connection with the server and send that frame to server.谁能告诉我这个代码1 ,这个 function 是否每次在获得新的视频帧时都会运行,如果是,那么我在第 188 行之后创建了一个线程,它基本上与服务器建立了 TCP 连接并将该帧发送到服务器。 But the problem is if this function runs every time it make every time new thread and make new socket connection, but I want this thread to make one time connection and then send frame every time it get to the already connected TCP socket.
但问题是,如果这个 function 每次都运行新线程并建立新的套接字连接,但我希望这个线程进行一次连接,然后每次到达已经连接的 TCP 套接字时发送帧。 The thread I am making is with this code,
我正在制作的线程是使用此代码,
Task task = new Task(() => { _helper.TcpConnectAndSend(originalBitmap); });
task.Start();
but I want this thread to make one time connection and then send frame every time it get to the already connected TCP socket.
但我希望这个线程进行一次连接,然后每次到达已经连接的 TCP 套接字时发送帧。
As Raymond Chen said, you called TcpConnectAndSend
each time after getting frame that will make connecting repeatedly.正如Raymond Chen 所说,你每次获取帧后都会调用
TcpConnectAndSend
,这会导致重复连接。
The better way is connect TCP socket after camera initialize , and then call send method for each fream.更好的方法是在相机初始化后连接TCP socket,然后为每个fream调用send方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.