In scenarios where there is more than one transaction being used, it is sometimes necessary to switch back and forth between them. Any transaction can be made the current transaction with the resume message.
The following example code illustrates this.
| transaction1 transaction2 | transaction1 := Transaction begin: 'firstTransaction'. transaction2 :=Transaction begin: 'secondTransaction'. Transaction current inspect.
The inspection shows that transaction2 is the current transaction.
| transaction1 transaction2 | transaction1 := Transaction begin: 'firstTransaction'. transaction2 := Transaction begin: 'secondTransaction'. transaction1 resume. Transaction current inspect.
In the above example, transaction1 is the current transaction because it was explicitly resumed.
| transaction1 transaction2 | transaction1 := Transaction begin: 'firstTransaction'. transaction2 := Transaction begin: 'secondTransaction'. transaction2 suspend. Transaction current inspect.
If a transaction is asked to suspend itself, the shared transaction will become the current transaction. This occurs only if the transaction being asked to suspend itself is actually the current transaction at the time it is suspended.
| transaction1 transaction2 | transaction1 := Transaction begin: 'firstTransaction'. transaction2 := Transaction begin: 'secondTransaction'. transaction1 suspend. Transaction current inspect.
In the above example, transaction2 is the current transaction after it is created, and transaction1 therefore cannot be suspended; transaction2 remains as the current transaction.