PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: shizny on March 30, 2008, 01:12:33

Title: notifications and thread blocking
Post by: shizny on March 30, 2008, 01:12:33
I'm having this problem with cancelling a database operation.  When someone clicks import on a form I have I begin running through a file and inserting information into the database.  I have opened the database asynchronously so I do not block the main application thread.  I have a cancel button that people can click to cancel/rollback the import process.  The cancel event does not get broadcast immediately, and I can't really figure out why it broadcasts when it does.  It registers the click about 50 percent of the way through the database operations.  Right now I have the cancel button calling a function in the mediator which, in turn, calls a proxy function that cancels the database action.  I though maybe I needed to send another notification from the mediator (the proxy call might be deferred until the other notice finishes), but that didn't work either.  I was reading that if a notification is sent out when another notification is running that the second notification will run and then when it is completed the thread will go back to the original notification.  Is this correct?  What could I be doing wrong?  When I access the file to import, could that be blocking the notifications?

Title: Re: notifications and thread blocking
Post by: shizny on March 31, 2008, 09:08:55
Question about commands.  If they are FIFO what happens when a command you call creates an asynchronous operation?  When the asynchronous operation starts is the command 'finished' and then another command can start?

Title: Re: notifications and thread blocking
Post by: puremvc on March 31, 2008, 12:11:43

As to the file i/o blocking I'm not sure what may be happning there.

For handling async operations, typically the proxy that started the operation sends a notification on completion. In addition to searching these forums for 'async' to find the threads that have batted the problem around, I would suggest having a look at the StartupManager AS3 utility and its accompanying demo 'Startup as Ordered' which handles async loading with dependencies, timeout/retry fault handling, etc.