Quantcast
Channel: Questions in topic: "pipe"
Viewing all articles
Browse latest Browse all 89

Unity doesn't support for NamedPipe?

$
0
0
Hello, I am really newbie with C# and Unity Scripting. I'm using NamedPipeStream for sending messages from Other process to Unity. But, is it possible to stop task while WaitForConnection() ? private void start_namedpipe() { PipeServerStream = new NamedPipeServerStream(pipeName, PipeDirection.In, 1, PipeTransmissionMode.Byte, PipeOptions.None, 4096, 4096); if (PipeServerStream != null) { try { task = Task.Run(async () => { //task_cancel_token.ThrowIfCancellationRequested(); while (true) { try { debug_msg = "Waiting For Connection . . . "; PipeServerStream.WaitForConnection(); debug_msg = "Client Connected !!"; while (PipeServerStream.IsConnected) { //check cancel task //if (task_cancel_token.IsCancellationRequested) // return; var read = new byte[4096]; await PipeServerStream.ReadAsync(read, 0, read.Length, task_cancel_token); var msg = Encoding.UTF8.GetString(read).TrimEnd('\0'); msg_msg = msg; } } catch (Exception e) { PipeServerStream.Disconnect(); debug_msg = "Client Disonnected !!"; continue; } finally { PipeServerStream.Disconnect(); } } }, task_cancel_token_source.Token); } catch (Exception e) { debug.text = e.ToString(); } } } I thought using WaitForConnectionAsync with Cancellation Token would work well, but it says "WaitForConnectionAsync is not implemented" so that i can't use it. Which means, i can't stop this task and close pipe stream maybe. And after using this pipe stream, maybe unclosed stream or tasks occurs this, The Unity Editor becomes "no response" and permantnt Application.Reload, and sometimes Application.Quit shows me same happens too. I can use TCP Sockets rather than pipes as well, but i have no idea that unity does not support pipe correctly maybe..

Viewing all articles
Browse latest Browse all 89

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>