Dispatcher.BeginInvoke Method (Action)

Executes the specified delegate asynchronously on the thread the Dispatcher is associated with.

Namespace:  System.Windows.Threading
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
Public Function BeginInvoke ( _
    a As Action _
) As DispatcherOperation
public DispatcherOperation BeginInvoke(
    Action a
)

Parameters

  • a
    Type: System.Action
    A delegate to a method that takes no arguments and does not return a value, which is pushed onto the Dispatcher event queue.

Return Value

Type: System.Windows.Threading.DispatcherOperation
An object, which is returned immediately after BeginInvoke is called, that represents the operation that has been posted to the Dispatcher queue.

Examples

The following code example demonstrates how to use this method.

Private testBeginInvokePanel As Panel

Private Sub TestBeginInvoke(ByVal p As Panel)
    testBeginInvokePanel = p
    p.Dispatcher.BeginInvoke(AddressOf AddTextByDispatcher)
End Sub

Private Sub AddTextByDispatcher()
    testBeginInvokePanel.Children.Clear()
    Dim t As New TextBlock
    t.Text = "Added by Dispatcher."
    testBeginInvokePanel.Children.Add(t)
End Sub
private void TestBeginInvoke(Panel p)
{
    p.Dispatcher.BeginInvoke(() => {
        p.Children.Clear();
        p.Children.Add(
            new TextBlock { Text = "Added by Dispatcher." });
    });
}

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.