Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: notifications and thread blocking  (Read 4234 times)
shizny
Full Member
***
Posts: 31


View Profile Email
« 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?
Logged
shizny
Full Member
***
Posts: 31


View Profile Email
« Reply #1 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?
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #2 on: March 31, 2008, 12:11:43 »

Shizny,

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.

-=Cliff>
Logged
Pages: [1]
Print