Using Async to wait for a specific event

I've simplified the creation and deletion calls and used a generic item.  In my before method, I call Async.handleEvent to wait for PropertyChangeEvents, but this only waits for the first one.  My problem lies in the fact that ItemManager is an IEventDispatcher that sends multiple property change events, but I need to wait for the specific event with the property "item".  However, when I call Async inside the handler, it does not keep the Test method from running, Before assumes that it's Async responsibilities have been fulfilled and launches the next stage of tests.  How can I keep Before from moving on until an event with a specific property has been received?
public class Test
        private static const TIME_OUT:int = 3000;
        [Before(async)]
        public function runBeforeEveryTest() : void
            // Create a new item
            item.create();  // This is an asynchronous creation that sends many Property Change events
            //Wait for the item to be created before continuing tests.
            Async.handleEvent( this, ItemManager.instance, PropertyChangeEvent.PROPERTY_CHANGE, handlePropertyChangeForItem, TIME_OUT);
        [After]
        public function runAfterEveryTest() : void
            // Delete the Item
            item.delete();
        [Test(async)]
        public function itemExists() : void
                  Assert.assertTrue( item.exists() );
       private function handlePropertyChangeForItem(evt:PropertyChangeEvent, eventObject:Object) : void
             if (evt.property == "item")
                 // Now that the item has been created, we can start the tests.
                 return;
             else
                 // Keep waiting.
                 Async.handleEvent( this, ItemManager.instance, PropertyChangeEvent.PROPERTY_CHANGE, handlePropertyChangeForItem, TIME_OUT);
Thanks in advance, it's greatly appreciated!

I can't reproduce this issue. All seems to be working fine with multiple deferred Async calls. I am pasting my code in. Since I did not have your manager, I tried to repiicate this with a timer. If you could look at my code and see if it differs from yours in a significant way, I can take another shot, but it seems to be working as expected.
package  
import flash.events.TimerEvent; 
import flash.utils.Timer; 
import mx.events.PropertyChangeEvent; 
import org.flexunit.Assert; 
import org.flexunit.async.Async; 
public class NestedAsync { 
private static const TIME_OUT:int = 3000; 
private var timer:Timer; 
Before(async)]
public function runBeforeEveryTest() : void {   timer =
new Timer( 1000, 5 ); 
  Async.handleEvent(this, timer, TimerEvent.TIMER, handleTimerTick, TIME_OUT);timer.start();}
[After]
public function runAfterEveryTest() : void {  timer.stop();
  timer =
null;}
Test(async)] 
public function itemExists() : void {Assert.assertTrue(
true );}
private function handleTimerTick(evt:TimerEvent, eventObject:Object) : void {  
  if ( timer.currentCount == 5 ) { 
    // Now that the item has been created, we can start the tests. 
    return;  }
  else  { 
    // Keep waiting.    Async.handleEvent(
this, timer, TimerEvent.TIMER, handlePropertyChangeForItem, TIME_OUT);
suite.cases { 

Similar Messages

  • How to use same RESULT SET for two different events

    hello friends,
    I need to use same result set for two different events. How to do it.
    here My code,
    private void jComboBox1ItemStateChanged(java.awt.event.ItemEvent evt) {
    // TODO add your handling code here:
    try
    String selstate,selitem;
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:tourismdatasource","sa","");
    selstate="select * from tab_places where state=?";
    PreparedStatement ps=con.prepareStatement(selstate);
    ps.setString(1, jComboBox1.getSelectedItem().toString().trim());
    ResultSet rs=ps.executeQuery();
    if(rs.next())
    jTextField1.setText(rs.getString("place_ID"));
    jTextField2.setText(rs.getString("place_name"));
    jTextField3.setText(rs.getString("category"));
    byte[] ba;
    ba=rs.getBytes("image");
    ImageIcon ic = new ImageIcon(ba);
    jLabel6.setIcon(ic);
    in=true;
    catch(ClassNotFoundException cfe){JOptionPane.showMessageDialog(null, cfe.getMessage());}
    catch(SQLException sqe){JOptionPane.showMessageDialog(null,sqe.getMessage());}
    Now i need the same Result Set(rs), in another event(jButton6ActionPerformed),
    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
    // TODO add your handling code here:
    }  how do i get dat resultset,
    help me out

    One post wasn't enough?
    {color:0000ff}http://forum.java.sun.com/thread.jspa?threadID=5246634{color}
    db

  • Can Ical display a picture for a specific event?

    Hello
    I was wondering if it is possible to display a picture for a specific event in ICal:
    For exemple if tomorrow it is someone birthday, I will like to see a picture of his face on my Ical
    I saw that on someone facebook I think it is called itoday
    Any help?

    Not really. For birthdays if you double-click the event there is a link to the Address Book entry, and you can have a picture there. For other events you can add a link to a picture file; double-click the event then follow the link to show the picture.
    I think iToday is some sort of online newspaper.
    AK

  • Query on Using fork with wait for event

    Hi All,
    I have a scenario in which a fork has two branches and one branch has the multiple steps along the line and also calls a subworkflow in one of the steps.
    The second branch has a single wait for event to complete the workflow in case of a cancel event.
    My understanding is that when the branch one executes and is on a single step decision or have gone inside a subworkflow and wating for user decision on the workitem created
    Whenever the wait event is triggered on the main workflow the second branch gets executed completing the workflow and all the branch one steps and the subworkflow gets logically deleted removing all the workitem from the inbox.
    Do I have to do any specific process control in main workflow to make sure that the subworkflow is deleted .
    Please clarify on this.
    Thanks,
    Charan.

    It should be taken care by itself. No additional steps required.
    Regards, IA

  • Wait for a specific time in SAP 4.6

    Hi Experts,
    Here is my issue.
    There is a custom workflow where I need to include one reminder mail task (in between the tasks) after 5 days.
    I have created wait step with an infinite wait event.
    I gave 5 days in the latest end option of the workflow.
    But now, the latest end option has created a new branch which just terminates the workflow.
    Is there any way I can swap the Latest End Branch and the Event Triggered Branch.
    Or is there any other way to make the workflow wait for 5 days..
    Thanks in advance,
    Sreekanth

    Hi,
    Use requested start tab.
    Kind regards, Rob Dielemans

  • Using ioctl to wait for hardware interrupt in user space in Petalinux

    I have a custom Network device driver for a device that generates two hardware interrupts, one every 20 ms and another every second. I have a separate interrupt handler registered for each interrupt. Each interrupt handler does nothing more than call "up" on a semaphore. There is a different semaphore associated with each interrupt.
    I want a user-space program to be notified when the interrupt occurs, so I have an ioctl defined with two commands. One is a command to wait for the 20 ms  interrupt and the other is a command to wait for the 1 second interrupt. In each case, the ioctl routine simply calls down_interruptible on the corresonding semaphore (the same semaphore modified by the interrupt handlers).
    In my user-space program, I create two pthreads. Each has an infinite loop to call each of the two ioctls described above.
    I am seeing that the user-space thread that waits for the 1 second interrupt is going to sleep and seems to be blocking the overall process. When the 1 second interrupt comes in, the thread wakes up and, in the process of handling the interrupt, allows the other thread to be tasked. The result is that exactly one 20 ms interrupt is handled each second, whenever a 1 second interrupt fires.
    I have tried enabling the O_NONBLOCK mode on the socket, but this did not make any difference. I'm not sure how to allow the second thread to continue to run, even while the first thread is asleep. Seems like this is the whole point of using pthreads.
    Any help would be appreciated.

    So, the issue was that I was trying to implement the ioctl in a network device. When you call ioctl on a socket, it apparently blocks the process until the ioctl completes.
    I implemented a character device inside my network driver and used this to handle the ioctls instead. Once I did this, I found that only the calling thread blocked on ioctl, not the entire process.

  • Using features while waiting for activation

    Reading an FAQ I am told that I can use iphone features while I wait for "further activation" while my phone number is being migrated. But I can't seem to be able to do this, anyone have any ideas?

    I'm in the same rocky boat as a lot of people. I waited 6-7 hours in line to get an iPhone from the Fifth Ave NYC store with my friend. We shot home quickly on the subway, all excited to get this baby up and running. My friend's iPhone had no problem going through the activation process via iTunes, but he is still waiting to have his service transfered from Sprint, so he can make calls on AT&T but can't receive any. But, at least his phone has been activated, so he can play with all the nice little features.
    I, on the other hand, got a notice at the end of the iTunes activation process saying that they basically need to take more time to activate my iPhone. Almost immediately, I got two email messages in my inbox. One says,
    "Phone service is scheduled to be disconnected on your current phone at or after 10:00 PM EDT on June 30. Please check your email and be prepared to reconnect and activate your iPhone before that time. Please call 877-800-3701 if you'd like to make other arrangements."
    Six minutes later, I got another email saying,
    "AT&T is now processing your activation. You will receive an email confirmation once your activation is complete."
    In other words, my LONG-AWAITED iPhone is just sitting here looking pretty. And, here I am, sitting here looking ticked off. I love Apple like you wouldn't believe, but this is really disappointing, although I probably should be pointing the finger AT&T's way. Since my iPhone hasn't even been activated in iTunes, the only thing the phone does is turn on to show me a picture of the earth and an "slide bar" telling me to "Slide For Emergency." I can't use any other functions.
    I was with Sprint for about 7 years with no late payments ever. I've been told by customer service that I'm one of their more valued customers, since I've been with them for so long and I always pay on time. This leads me to believe that it's some problem with AT&T. What a disappointment that I might not be able to use my iPhone for over a day after I bought it.
    Take note, Apple & AT&T. Learning experiences for sale.

  • HT4623 I'm new to using apple products, recently was asked to consider using a ipad mini for my specific business needs. Does anyone use the mini for their business?  How does it work for you?

    I'm new to using the apple OS.  Recently had business partner buy an ipad mini, was thinking of buying more for our businesses.  I'm used to using Windows Office products for my reports, wanted to know how apple's Pages, Keynote and Numbers compared and whether they could be used on the ipad mini. 

    I have asked a moderator to provide assistance, they will post an invite on this thread.
    Once you get a reply, if you click on their name, you will see a screen like this. Click on the link as shown below.
    Please do not send them a personal message, as they may not be on duty for a long time, and your message will not be tracked properly.
    There are some useful help pages here, for BT Broadband customers only, on my personal website.
    BT Broadband customers - help with broadband, WiFi, networking, e-mail and phones.

  • Only wait for a specific condition for 10 seconds?

    I have a thread that waits to get notified by another thread. But this thread might crash and therfore never notifiy the waiting thread.
    Is it possible for a thread to wait for a notification for only 10 seconds?

    You're invoking wait(), right? Look at the API documentation, and you'll easily see other flavors of that method which allow you to specify timeouts.
    Make the API documentation part of your toolset.
    http://java.sun.com/j2se/1.5.0/docs/api/index.html
    That said, I'd first concentrate on fixing the thread code which you say "might crash". Anything else you do to work around that is just a dirty band-aid approach.

  • Alarm for a specific event and time

    My alarm works just fine, if I set it to ring like an alarm clock.  The problem is that from time to time if I enter a specific time and event, it will not alarm.
    For example:
    9:00 AM.  Phone home
    The alarm indicator will be checked in the preferences area, but no alarm will will "go off".  This does not happen all of the time.  What can I do?

    The only app that I know of that will sound an alarm even if the phone is muted is the built in Clock app. It does not have the ability to set an alarm for a specifc date. So, no, I don't believe what you want to do is possible.

  • How to find if a alert already exists for a specific Event id or Performance counter in SCOM

    Hi Experts,
    I am using SCOM 2007 R2 with CU4. In our team we have few requirements for alerts, But before i get them created for my team i would like to know if there is already a default or customized alert created for it or not. Is there any way to find this via powershell
    or via SQL query? For both Event id's and Performance counters.

    Hi,
    We may use get-scomalert command:
    Get-SCOMAlert -computername computername -Name alertname
    By using SQL query:
    SELECT
    TA
    .[AlertName]
    ,BM.[Fullname]
    FROM
    [OperationsManager].[dbo].[Alert]
    AS
    TA
    join
    [OperationsManager].[dbo].[Basemanagedentity]
    AS
    BM
    ON
    TA.BaseManagedEntityId=BM.BaseManagedEntityId
    WHERE
    AlertName
    like
    '%alertname%';
    Regards,
    Yan Li
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • How to make component listen for a specific event of another component

    for example, i have several buttons and want them listen for a TreeSelectionEvent... in case anything selected they become active
    i don't want a JTree component activate these buttons...

    here's an overkill,
    import java.util.*;
    abstract class DoWhatever {
        public static Hashtable ht = null;
        public static Object DoWhat( String s, Object obj ) {
         if( null == ht ) {
             ht = new Hashtable();
             ht.put( ThisDoWhatever.NAME, new ThisDoWhatever() );
             ht.put( ThatDoWhatever.NAME, new ThatDoWhatever() );        
         return ( (DoWhatever) ht.get( s ) ).doWhatever( obj );
        public abstract Object doWhatever( Object obj );
    class ThisDoWhatever extends DoWhatever {
        public final static String NAME = "this";
        public Object doWhatever( Object obj ) {
         System.out.println( NAME );
         return null;
    class ThatDoWhatever extends DoWhatever {
        public final static String NAME = "that";
        public Object doWhatever( Object obj ) {
         System.out.println( NAME );
         return null;
    public class DoThisOrThat {
        public static void main( String[] args ) {
         DoWhatever.DoWhat( args[ 0 ], null );
    }

  • Wait for Event step in Workflow (Urgent).

    Hi,all!
    I am unable to implement the wait for event successfully in my workflow..
    Sceanrio: I have created a container element in the WF with of type a <b>BOR(ISUPARTNER)</b> whose <b>CREATED</b> event is being waited for in the workflow.
    Then in the <b>WAIT FOR EVENT</b> step in WF I m giving putting in the details  of the event..
    Then putting a send mail after this.
    Problem: Now my workflow is throwing error and the send mail task is not executed even after the said event is done in the system..
    Plz... suggest as to how to do it..
    Thanks,
    Sudipto

    <i>Now for this I m actually creating a container element of type BOR B in my workflow n putting a step WAIT FOR EVENT in which I m putting the CREATED event. For triggering the CREATED event no instance is required...</i>
    - Once again, Wait For Event step is only possible when the Object Key is available to the Workflow container when the flow reaches the event (are you waiting for a specific ISUPARTNER to be created or you don't care as long as some ISUPARTNER is created).
    <i>my event CREATED is not getting triggered automatically...</i>
    - First check if the standard system triggers the event for your object. If not explore different options for doing that.
    For your scenario, check if you can trigger a custom event BORB_Created for BORA when BORB is created and use BORA in the Wait step.
    Please post future Workflow questions in the Business Process Management forum.
    Cheers,
    Ramki Maley.
    Message was edited by: Ramki Maley
    Message was edited by: Ramki Maley

  • How to make a component wait for an event?

    Hey there Adobe community, I recently started using Flash Builder and I have a problem. I have a windowed application in Flash Builder with some script code and then a base64 image.
    <?xml version="1.0" encoding="utf-8"?>
    <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                           xmlns:s="library://ns.adobe.com/flex/spark"
                           xmlns:mx="library://ns.adobe.com/flex/mx"
                           xmlns:flexlib="http://code.google.com/p/flexlib/" preinitialize="loadImage()">
        <fx:Script><![CDATA[
            import flash.display.BitmapData;
        import flash.utils.ByteArray;
        import mx.controls.Image;
        import mx.core.UIComponent;
        import mx.graphics.codec.JPEGEncoder;
        import mx.utils.Base64Encoder;
        private var image:Bitmap;
        private var base64image:String="";
        private function loadImage():void
            var loader:Loader = new Loader;
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
            loader.load(new URLRequest("mypic.jpg"));
            trace("started loading");
        private function getimg():String
            trace("flexlib accessing image ", base64image);
            return base64image;
        private function imageLoaded(event:Event):void
            image = new Bitmap(event.target.content.bitmapData);
            base64image = getBase64FromComponent(image);
            trace("image converted");
        ]]></fx:Script>
        <flexlib:Base64Image value="{getimg()}"/>
    </s:WindowedApplication>
    The flexlib tag should render an image from a string. I want to load an image in the actionscript code, convert it to a string and then draw it. However, as soon as the application starts it attempts to render the string, which is still empty.
    The trace is like this, for some reason the getimg() is called twice:
    flexlib accessing image
    started loading
    flexlib accessing image
    image converted
    As you can see, the image isn't converted until after flexlib tries to draw it. The solution would be to make the flexlib component wait for the imageLoaded event, or make the specific tag re-initialize itself. How can I do this?

    Great, thanks. Now I can narrow my problem scope down.
    This is now the isolated culprit of my program:
    "Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space"
    I already ran garbage collector just before 2nd method but the same error still occures.
    But if I were to comment out method 2, run the program (to generate the file from method 1), then do the opposite and run again, it will work. ie. I have to run the main program twice.
    I don't understand this. The free memory after running GC after method 1 has reset the free mem to approx 1654kb so why can't method 2 run properly?
    Even if I just run method 2 alone, the free mem it starts with is 1639kb.
    Here are the memory values during the execution.
    //all memory values in kb
    Max memory = 65088
    Allocated memory = 1984
    total free memory: 64743
    free memory before method 1: 1639
    // Run method 1
    free memory after method 1: 875
    free memory after running garbage collector: 1654
    //Run method 2
    free memory after the main computation in method 2: 4807
    free memory AFTER running garbage collector: 6733
    Any solutions?

  • Wait for event step without callback

    Hi All,
    In 4.6C I have the following problem:
    We have a workflow that has a fork with 2 branches, with 1 necessary for continuing the fork.
    One of the branches has a dynamic parallel processing step on a multiline container element, where each parallel process is a wait for event step. For example if the multiline element has 5 records, than there will be 5 parallel wait for event steps on this branch, and if all 5 are completed, then the workflow continues after the fork and the other branch should be logically deleted (normal behaviour).
    The other branch has a single wait for event step, if this event is received, the other branch's parallel wait for event steps should be deleted to continue.
    The problem is that when the event for the latter single wait step is received, the step gets completed, but sometimes the parallel wait for event steps on the other branch are not deleted and the wokflow does not continue. The completed wait for event step shows that the callback is not completed yet.
    I tried to fix these steps in SWPC, but in 4.6C it does not work for wait for event steps w/o callback. There's an OSS note for higher releases where this is fixed to enable SWPC for wait for events, so I copied it to a custom program and use that right now.
    First question is why does the system not continue these workflow's when the event is received? My guess is that the tRFC calls get stuck and when the tRFC job reprocesses the entries, it does not do it correctly. For example lately we had a tablespace problem that caused some tRFC calls to go into error. The waiting steps in the instances were completed w/o callback. I reprocessed the tRFC entries, which created new entries in the Workflow logs showing that the events are received, but the workflows still hang.
    Second question, it takes a lot of time to logically delete those parallel wait for event steps. When the event for the single wait for event is received and the workflow continues w/o problem, it may take tens of minutes from the receipt of the event until the parallel wait for event steps get deleted and the WF continues. Why does it take so long?
    Thanks,
    KK

    Hi,
    Regarding the delay and the hundreds of thousand SWW_CONT updates... the main workflow on one branch does a dynamic parallel processing of a subworkflow using a multiline container element that can have 50 or even 100 elements. So we can have 50 or even 100 subworkflows waiting for their event to be triggered.
    The main workflow container contains many elements, some multiline with long structures, so in one instance the main flow had 8000 entries in SWW_CONT (each field of a structure is a separate record in SWW_CONT).
    Now if I do the math, when this workflow loads all the container elements of the main flow into the 100 waiting subflows before deleting them and continuing along the other branch, it creates 100 times 8000 entries in SWW_CONT, that is 800.000 inserts!
    And this was ONE single workflow.. Imagine when we have just a few hundred and they all want to continue at the same time...
    Anyway, the beauty comes now....
    I created a simple main flow with a single multiline import parameter USERS of object USER. It has a fork with 2 branches, 1 enough to continue. One branch is a user decision with 1 option: Continue. The other branch has a subworkflow and it does dynamic parallel processing with the multiline element USERS.
    The subworkflow has one single import element USER of object USER. It has only one step, a wait for event, waiting for the DELETED event of the USER object.
    That's the scenario.
    When I start the main flow, filling the USERS parameter with two user objects, on the first branch it starts the two parallel waiting subflows with one user each, and I get the decision step on the other branch. If I check the subflow containers this time, they only have one USER object each.
    Now if I complete the user decision, the workflow continues, logically deletes the subflows and completes. If I check the subflow containers after this, they all include the USERS multile container element with all the USERS I started the main flow with!
    So this time it was a different main flow, different subflow, different events. I guess there can't be any custom code doing this, unless there's some generic workflow user exit somewhere.
    Feel free to test this yourselves if you have 4.6C, quite easy scenario. Guess I'll try in ECC 6.0 too just to see...
    And I'll report to SAP for sure.
    Regards,
    Krisztian Klausz

Maybe you are looking for

  • Embedded video in PDF shows blank

    Hi, I am using Acrobat 9 Pro. I have a PDF and a .mp4 video on a web-server. The mp4 is about 26 Mb in size. If I open the video on the browser (IE) it works. However when I embed this video in my PDF using a 'Video tool' it plays only the audio and

  • Web.show_document to print reports

    hi, i am using web.show_document to print reports. when i print a report, a new browser window is displayed, i don't want this to happen, or at least close the windows that appear automatically, i hope someone can help me.

  • Jain SIP sample code to do a VOIP...

    Hi, Right now I have a problem with my current project, can somebody give me some sample codes/can help me on how to make an client VOIP application using Jain SIP API to do a VOIP call... I have an PBX Server but i dont know how to start writing my

  • Dynamic Link Media Server Cannot be Found-

         Hi, everybody:      I am trying to retouch two video files in Photoshop CS6 Extended for Mac OS X, and I cannot find the dynamic link media server. I never had this problem before. It says a component is missing. I downloaded the update to the s

  • Insering Xmltype of Oracle 12C in JDBC

    HI Team, Can anyone help to inserting the xmltype columns into Oralce 12C from Java - JDBC. For connecting Ora-12C, I have import ojdbc7.jar file and for inserting xmltype into the db, it is expecting oracle\jdbc\oci8\OCIDBAccess which is available i