Exporter (0) Imprimer
Développer tout

Dispatcher.BeginInvoke Method (Delegate, Object[])

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

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

public DispatcherOperation BeginInvoke(
	Delegate d,
	params Object[] args
)

Parameters

d
Type: System.Delegate
A delegate to a method that takes multiple arguments, which is pushed onto the Dispatcher event queue.
args
Type: System.Object[]
An array of objects to pass as arguments to the specified method.

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.

The following code example demonstrates how to use this method.


private delegate void AddTextDelegate(Panel p, String text);

private void AddText(Panel p, String text)
{
    p.Children.Clear();
    p.Children.Add(new TextBlock { Text = text });
}

private void TestBeginInvokeWithParameters(Panel p)
{
    if (p.Dispatcher.CheckAccess()) AddText(p, "Added directly.");
    else p.Dispatcher.BeginInvoke(
        new AddTextDelegate(AddText), p, "Added by Dispatcher.");
}


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

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

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

Ajouts de la communauté

AJOUTER
Afficher:
© 2014 Microsoft