private void Dispose(bool disposing) { if (!this.disposed) { PipeConnection.Dispose(); if (PipeThread != null) { try { PipeThread.Abort(); } catch (System.Threading.ThreadAbortException ex) { } catch (System.Threading.ThreadStateException ex) { } catch (Exception ex) { // Log exception } } } disposed = true; }
public void StartPipeServer() { isListening = true; ServerPipeConnection PipeConnection = new ServerPipeConnection(pipeName, 512, 512, 5000, false); Task.Run(() => { while (isListening) { PipeConnection.Disconnect(); PipeConnection.Connect(); try { string request = PipeConnection.Read(); onMessage?.Invoke(this, JsonConvert.DeserializeObject <pipeMessageData <object> >(request)); } catch (Exception ex) { } } PipeConnection.Dispose(); }); }