public void NotifyListenersWeAreDone(ClousotAnalysisResults results) { Contract.Requires(results != null); results.NotifyDone(); var namedPipeClient = new NamedPipeClientStream(".", CommonNames.GetPipeNameForCCCheckPulseCallBack(0), PipeDirection.InOut); try { #if DEBUG && DEBUG_PRINT Console.WriteLine("[Debug] Trying to connect to the server to write back (we also wait {0})", TIMEOUTFORCONNECTION); #endif namedPipeClient.Connect(TIMEOUTFORCONNECTION); new PipeStreamSimple(namedPipeClient).WriteIfConnected(results.ToList()); #if DEBUG && DEBUG_PRINT Console.WriteLine("[Debug] We are done writing back"); #endif } catch (Exception #if DEBUG && DEBUG_PRINT e #endif ) { #if DEBUG && DEBUG_PRINT Console.WriteLine("[Debug] We failed in writing back: {0}", e.Message); #endif // do nothing } finally { namedPipeClient.Close(); } }
public CCCheckPulseForm() { InitializeComponent(); SetUpGrids(); SetUpTimer(); //this.myCallBackPipe = CommonNames.GetPipeNameForCallBack(Process.GetCurrentProcess().Id); this.myCallBackPipe = CommonNames.GetPipeNameForCCCheckPulseCallBack(0); // Start the worker thread for call backs var listenerThread = new Thread(CallBack); listenerThread.IsBackground = true; // To make sure that when we close the window, we exit even if the background listener is still waiting for a connection listenerThread.Start(); }