I need a run-only-once method that when all the criteria are met, say A&B&C are true, run the codes once, but only once. So if later on all the criteria are met again (A&B&C are true again but I don't care then), the code won't be run again.
This is not to solve the multithread issue, there is no data synchronization problem here, just later on all the criteria may be met again.
I have tried a method like this: add another property, update it when some criterion is met. When all the criteria are met, run the code, then set it to a special value, which will prevent it from running again.
For example, set its initial value to 1, when A is true &2, when B is true &4, when C is true & 8, so when it is 15, run the codes and set its value to 0. so later on, it will never be 15 again.
I was wondering if there a better way?