Sdílet prostřednictvím


Handling asynchronous processes during playback

If your Visual Studio Tools form makes asynchronous calls to other processes that the macro system will need to wait for, you may need to override the IsAsynchEventPending() method of the DexUIForm base class. This method is called periodically when a macro is being played. If the method returns true, the macro system will wait for the asynchronous event to finish before additional macro statements are processed.

Warning: Override the IsAsynchEventPending() method only if your Visual Studio Tools add-in has asynchronous processes that the macro system must wait for.

The following C# example shows how you override the method from the base class. Typically, you will create your own flag that tracks whether your add-in is running an asynchronous process. In the IsAsynchEventPending() method, you will return the value of this flag. When the asynchronous process starts, you will set the flag to true. This causes the macro system to wait for the asynchronous event. When the asynchronous process finishes, you will set the flag to false. This will allow the macro system to resume processing.

public override bool IsAsyncEventPending
{
    get
    {
        // Return the value of the flag that indicates whether an
        // asynchronous event is being processed.
        return InAsyncEventFlag;
    }
}