Nils Hoffman reported the following solution below in email. I think something like this may be the best direction rather than relying on Skyline itself to send an event before closing. But, it would also be nice if the implementation could be wrapped as an event in the SkylineTool library.
please find part (sans custom event and listener implementation) of our current workaround for the Skyline pipe connection checking below.
The "pipe" is what we receive from Skyline on startup. We basically construct a new read-only pipe stream which we poll regularly. Not sure whether this could be
done more elegantly with a notification mechanism, but this ensures, that we terminate in any case if Skyline is no longer there or doesn't respond. Comments welcome :-)!
skylineToolClient = new SkylineToolClient(pipe, "LipidCreator");
skylineToolClient.DocumentChanged += OnDocumentChanged;
skylineToolClient.SelectionChanged += OnSelectionChanged;
log.Info("LipidCreator is connected to Skyline file: '" + skylineToolClient.GetDocumentPath()+"'");
var client = new NamedPipeClientStream(@".", pipe, PipeDirection.In);
log.Info("Opening connection to Skyline through pipe " + pipe);
log.Info("Connected to Skyline through pipe " + pipe);
log.Debug("Checking Skyline pipe connection!");
var nServers = client.NumberOfServerInstances;
log.Debug(nServers+" servers available on other end of pipe!");
if (client.NumberOfServerInstances == 0)
log.Info("Skyline connection was terminated from the other side! Bye bye!");