Problem Background
I've created a "One-Click" publication process for my Flash (*.fla) project files with a C# program that performs the following operations:
- Updates a static "version" variable in two main project files (one for each FLA project)
- Alters an embedded JSFL template file (automates the opening/publishing of a specific FLA file) and writes it to disk to be used in the next step
- Calls Flash Professional via Process.Start, passing the path to flash.exe as well as the JSFL filename as an argument, so flash runs the JSFL file and publishes the project
- Publishes project files to my web server (simple backup/file-copy via mapped shared drive over Win7<->WinServer2012 VPN tunnel)
The UI has three buttons, one to publish the first project, one to publish the 2nd project, and one to publish both projects. The second project depends on the first project, so if and when the "publish both" button is clicked, it should completely finishing publishing the first file before publishing the second.
For each project, it reads the main document class AS file into memory as a string and uses a Regex to update specific static "version" variables to have a current timestamp. It then rewrites the files with the updated version. The purpose of the "version" variable is to be displayed at runtime in browser so I'm certain I'm testing the most recently compiled version of the project.
Flash Professional accepts a JSFL file name as a command line argument, but does not allow further arguments to be passed to that JSFL file, so the program alters a JSFL template to include the proper parameters and passes the customized temporary JSFL file to Flash Professional via Process.Start.
Publication to web occurs via another generic features that lets me specify a list of source and target paths (with optional timestamped backup of each file), that automates the backup and copying of specific published files to my web server.
Problem
First of all, I should mention that everything works fine when I'm publishing only one project file, and the issue I'm trying to solve is one of timing or event signaling.
Flash is a single-instance-only application, so running Process.Start will either start Flash Professional if it's not already running and run the JSFL script, or it will run the JSFL script in the existing instance of Flash Professional.
The first problem is after calling Process.Start, I cannot call waitForExit for the task to complete, because Flash stays open. If Flash is already open, waitForExit actually returns pretty quickly, because the 2nd Flash.exe instance will close after forwarding the command to the primary instance. Single-instance-only applications don't actually prevent a 2nd process from starting, they just quickly kill the 2nd process when it detects one is already running and forwards the command to it. For that reason, I cannot simply wait on the process to exit, since Flash may or may not be open.
Assuming I don't wait at all, my application will rather quickly call Process.Start twice, once for each project, passing a unique JSFL script filename to run for each one. The problem with this is that the first call seems to be discarded. I'm not sure if this behavior is rooted in the Windows OS or in the Flash Professional application. This occurs when Flash is not already open. The initial Process.Start call and corresponding parameters should be what activates Flash, so I would have expected that to make it through, however as Flash is starting up, when it finally shows the main window, it's only the 2nd script that runs.
Interstingly, if Flash is already started, both scripts appear to run despite their rapid activation (I see both documents open in the IDE), but the simultaneous publication actually causes Flash to crash (the main window disappears and the process terminates abruptly without any error).
So I need a way to coordinate issuing these Process.Start commands. Thankfully, the JSFL "publish" method is synchronous and JSFL is capable of executing command line commands, so perhaps once the publish method returns I can just call some external EXE to function as a coordination mechanism to detect when each script has completed its work before executing the next one? Does anyone have any experience with this kind of inter-process communication who could help me out?
TL;DR
I need to know how to build a simple executable such that when called from the command line, it sends a message to a specific external process, indicating that an operation has completed. Basically, a JSFL script running in Flash Professional must call the exe via the "undocumented" FLfile.runCommandLine method once the file has finished publishing, and that exe must then notify my automation program so it knows Flash has finished publishing the file and is ready to run another JSFL script to publish the next file.