In reply to Grumpy: [Just seen this bug - was trying to figure out which addon kept equiping greens instead of my epics before I realised it was the disenchant issue.
Could the event UNIT_SPELLCAST_START be used to fix that? That triggers when a spell starts to cast, so if the unit is the player and the spell is disenchant then select the item, so it should only happen on sucessful disenchant cast?]
I don't know anything about Bambo's implementation but I'm guessing he goes the much simpler route of attempting to cast, check if channeling/casting, "wait" until cast is done.
The alternative is to attempt casting start, mark something saying we should be casting, and wait for both a corresponding UNIT_SPELLCAST_START and UNIT_SPELLCAST_SUCCESS/FAIL (I think that's what it's called, if not the spellcast success/fail events XD) and mark appropriate variables to tell the yielding function that the spellcast is finished. Not that hard to do unless you already do it the first way, then it's a decent sized architectural change.
But I'm just guessing how Bambo did it XD