One of my workflows (I call it "leaf workflow") would be invoked by different other workflow instances from one request or possibly multiple requests of the same "Request Offering" at the same time, but I only want the "leaf workflow" be executed for one request.
To archive that, I have the top workflow grab and save a "global counter value" as a base so that when the "leaf workflow" is invoked later by whoever, it checks if it has a "token" (explained below). If it has the token, then it moves on and executes; otherwise, it exits.
The token is the value of the saved "global counter value" + 1. In the "leaf workflow", I use the logic the saved "global counter value" + 1 == GetNextCounter(CounterName) to see if the current leaf workflow instance got the token. GetNextCounter(CounterName) will return the next value of the counter, and it should not be ambiguous in multi-thread environment for one request (I have to use some other way to deal with multiple requests situation). However, I got inconsistent results, so I am lost. It's so hard to debug with the tool and there seems to be no "local" variables in a workflow for identification purposes. I am trying to use workflow instance Event ID, but I don't see a way to access it. Any suggestions would be greatly appreciated.