Dispatcher.Invoke Metodo
Definizione
Esegue in modo sincrono il delegato specificato sul thread al quale Dispatcher è associato.Executes the specified delegate synchronously on the thread the Dispatcher is associated with.
Overload
Invoke(DispatcherPriority, TimeSpan, Delegate, Object, Object[]) |
Esegue in modo sincrono il delegato specificato con la priorità e gli argomenti specificati sul thread al quale Dispatcher è associato.Executes the specified delegate at the specified priority with the specified arguments synchronously on the thread the Dispatcher is associated with. |
Invoke(DispatcherPriority, TimeSpan, Delegate, Object) |
Esegue in modo sincrono il delegato specificato con la priorità e l'argomento specificati sul thread al quale Dispatcher è associato.Executes the specified delegate at the specified priority with the specified argument synchronously on the thread the Dispatcher is associated with. |
Invoke(DispatcherPriority, Delegate, Object, Object[]) |
Esegue in modo sincrono il delegato specificato con la priorità e gli argomenti specificati sul thread al quale Dispatcher è associato.Executes the specified delegate at the specified priority with the specified arguments synchronously on the thread the Dispatcher is associated with. |
Invoke(Action, DispatcherPriority, CancellationToken, TimeSpan) |
Esegue in modo sincrono il Action specificato con la priorità specificata sul thread al quale Dispatcher è associato.Executes the specified Action synchronously at the specified priority on the thread the Dispatcher is associated with. |
Invoke(DispatcherPriority, TimeSpan, Delegate) |
Esegue in modo sincrono il delegato specificato con la priorità e il valore di timeout specificati sul thread al quale Dispatcher è associato.Executes the specified delegate synchronously at the specified priority and with the specified time-out value on the thread the Dispatcher was created. |
Invoke(DispatcherPriority, Delegate, Object) |
Esegue in modo sincrono il delegato specificato con la priorità e l'argomento specificati sul thread al quale Dispatcher è associato.Executes the specified delegate at the specified priority with the specified argument synchronously on the thread the Dispatcher is associated with. |
Invoke(Delegate, TimeSpan, DispatcherPriority, Object[]) |
Esegue in modo sincrono il delegato specificato entro l'intervallo di tempo designato con la priorità e gli argomenti specificati sul thread al quale Dispatcher è associato.Executes the specified delegate within the designated time span at the specified priority with the specified arguments synchronously on the thread the Dispatcher is associated with. |
Invoke(Delegate, TimeSpan, Object[]) |
Esegue in modo sincrono il delegato specificato entro l'intervallo di tempo designato con la priorità e gli argomenti specificati sul thread al quale Dispatcher è associato.Executes the specified delegate within the designated time span at the specified priority with the specified arguments synchronously on the thread the Dispatcher is associated with. |
Invoke(Action, DispatcherPriority, CancellationToken) |
Esegue in modo sincrono il Action specificato con la priorità specificata sul thread al quale Dispatcher è associato.Executes the specified Action synchronously at the specified priority on the thread the Dispatcher is associated with. |
Invoke(DispatcherPriority, Delegate) |
Esegue in modo sincrono il delegato specificato con la priorità specificata sul thread al quale Dispatcher è associato.Executes the specified delegate synchronously at the specified priority on the thread that the Dispatcher is associated with. |
Invoke(Delegate, Object[]) |
Esegue in modo asincrono il delegato specificato con gli argomenti specificati sul thread al quale Dispatcher è associato.Executes the specified delegate with the specified arguments synchronously on the thread the Dispatcher is associated with. |
Invoke(Action, DispatcherPriority) |
Esegue in modo sincrono il Action specificato con la priorità specificata sul thread al quale Dispatcher è associato.Executes the specified Action synchronously at the specified priority on the thread the Dispatcher is associated with. |
Invoke(Action) |
Esegue in modo sincrono il Action specificato sul thread al quale Dispatcher è associato.Executes the specified Action synchronously on the thread the Dispatcher is associated with. |
Invoke(Delegate, DispatcherPriority, Object[]) |
Esegue in modo sincrono il delegato specificato con la priorità e gli argomenti specificati sul thread al quale Dispatcher è associato.Executes the specified delegate at the specified priority with the specified arguments synchronously on the thread the Dispatcher is associated with. |
Invoke<TResult>(Func<TResult>) |
Esegue in modo sincrono il Func<TResult> specificato sul thread al quale Dispatcher è associato.Executes the specified Func<TResult> synchronously on the thread the Dispatcher is associated with. |
Invoke<TResult>(Func<TResult>, DispatcherPriority) |
Esegue in modo sincrono il Func<TResult> specificato con la priorità specificata sul thread al quale Dispatcher è associato.Executes the specified Func<TResult> synchronously at the specified priority on the thread the Dispatcher is associated with. |
Invoke<TResult>(Func<TResult>, DispatcherPriority, CancellationToken) |
Esegue in modo sincrono il Func<TResult> specificato con la priorità specificata sul thread al quale Dispatcher è associato.Executes the specified Func<TResult> synchronously at the specified priority on the thread the Dispatcher is associated with. |
Invoke<TResult>(Func<TResult>, DispatcherPriority, CancellationToken, TimeSpan) |
Esegue in modo sincrono il Func<TResult> specificato con la priorità specificata sul thread al quale Dispatcher è associato.Executes the specified Func<TResult> synchronously at the specified priority on the thread the Dispatcher is associated with. |
Esempio
Nell'esempio seguente viene inserito un delegato su un oggetto Dispatcher in Normal utilizzando Invoke .The following example places a delegate onto a Dispatcher at Normal using Invoke.
// Places the delegate onto the UI Thread's Dispatcher
private void timer_Elapsed(object sender, ElapsedEventArgs e)
{
// Place delegate on the Dispatcher.
this.Dispatcher.Invoke(DispatcherPriority.Normal,
new TimerDispatcherDelegate(TimerWorkItem));
}
' Places the delegate onto the UI Thread's Dispatcher
Private Sub timer_Elapsed(ByVal sender As Object, ByVal e As ElapsedEventArgs)
' Place delegate on the Dispatcher.
Me.Dispatcher.Invoke(DispatcherPriority.Normal, New TimerDispatcherDelegate(AddressOf TimerWorkItem))
End Sub
Commenti
In WPF solo il thread che ha creato un DispatcherObject può accedere a tale oggetto.In WPF, only the thread that created a DispatcherObject may access that object. Ad esempio, un thread in background che viene girato dal thread principale dell'interfaccia utente non può aggiornare il contenuto di un oggetto Button creato nel thread UI.For example, a background thread that is spun off from the main UI thread cannot update the contents of a Button that was created on the UI thread. Affinché il thread in background acceda alla proprietà Content di Button , il thread in background deve delegare il lavoro all'oggetto Dispatcher associato al thread dell'interfaccia utente.In order for the background thread to access the Content property of the Button, the background thread must delegate the work to the Dispatcher associated with the UI thread. Questa operazione viene eseguita usando Invoke o BeginInvoke .This is accomplished by using either Invoke or BeginInvoke. Invoke è sincrono ed BeginInvoke è asincrono.Invoke is synchronous and BeginInvoke is asynchronous. L'operazione viene aggiunta alla coda degli eventi di Dispatcher in corrispondenza dell'oggetto specificato DispatcherPriority .The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
Invoke è un'operazione sincrona. Pertanto, il controllo non tornerà all'oggetto chiamante finché non viene restituito il callback.Invoke is a synchronous operation; therefore, control will not return to the calling object until after the callback returns.
Invoke(DispatcherPriority, TimeSpan, Delegate, Object, Object[])
Esegue in modo sincrono il delegato specificato con la priorità e gli argomenti specificati sul thread al quale Dispatcher è associato.Executes the specified delegate at the specified priority with the specified arguments synchronously on the thread the Dispatcher is associated with.
public:
System::Object ^ Invoke(System::Windows::Threading::DispatcherPriority priority, TimeSpan timeout, Delegate ^ method, System::Object ^ arg, ... cli::array <System::Object ^> ^ args);
[System.ComponentModel.Browsable(false)]
public object Invoke (System.Windows.Threading.DispatcherPriority priority, TimeSpan timeout, Delegate method, object arg, params object[] args);
[<System.ComponentModel.Browsable(false)>]
member this.Invoke : System.Windows.Threading.DispatcherPriority * TimeSpan * Delegate * obj * obj[] -> obj
Public Function Invoke (priority As DispatcherPriority, timeout As TimeSpan, method As Delegate, arg As Object, ParamArray args As Object()) As Object
Parametri
- priority
- DispatcherPriority
Priorità, relativa alle altre operazioni in sospeso nella Dispatcher coda degli eventi, con cui viene richiamato il metodo specificato.The priority, relative to the other pending operations in the Dispatcher event queue, with which the specified method is invoked.
- timeout
- TimeSpan
Tempo massimo di attesa per l'avvio dell'operazione.The maximum amount of time to wait for the operation to start. Una volta avviata, l'operazione verrà completata prima che questo metodo venga restituito.Once the operation has started, it will complete before this method returns. Per specificare un'attesa infinita, usare un valore pari a-1.To specify an infinite wait, use a value of -1. In una chiamata allo stesso thread, qualsiasi altro valore negativo viene convertito in-1, ottenendo un'attesa infinita.In a same-thread call, any other negative value is converted to -1, resulting in an infinite wait. In una chiamata cross-thread, qualsiasi altro valore negativo genera un'eccezione ArgumentOutOfRangeException .In a cross-thread call, any other negative value throws an ArgumentOutOfRangeException.
- method
- Delegate
Delegato a un metodo che accetta più argomenti, inserito nella coda degli eventi di Dispatcher.A delegate to a method that takes multiple arguments, which is pushed onto the Dispatcher event queue.
- arg
- Object
Oggetto da passare come argomento al metodo specificato.An object to pass as an argument to the specified method.
- args
- Object[]
Matrice di oggetti da passare come argomenti al metodo specificato.An array of objects to pass as arguments to the specified method.
Restituisce
Valore restituito dal delegato richiamato oppure null
se il delegato non restituisce alcun valore.The return value from the delegate being invoked or null
if the delegate has no return value.
- Attributi
Eccezioni
priority
non è un oggetto DispatcherPriority valido.priority
is not a valid DispatcherPriority.
method
è null
.method
is null
.
timeout
è un numero negativo diverso da-1 e questo metodo è stato richiamato tra thread.timeout
is a negative number other than -1, and this method was invoked across threads.
Commenti
arg
può essere null
se non è necessario un argomento.arg
can be null
if an argument is not needed.
In WPF solo il thread che ha creato un DispatcherObject può accedere a tale oggetto.In WPF, only the thread that created a DispatcherObject may access that object. Ad esempio, un thread in background che viene girato dal thread principale dell'interfaccia utente non può aggiornare il contenuto di un oggetto Button creato nel thread UI.For example, a background thread that is spun off from the main UI thread cannot update the contents of a Button that was created on the UI thread. Affinché il thread in background acceda alla proprietà Content di Button , il thread in background deve delegare il lavoro all'oggetto Dispatcher associato al thread dell'interfaccia utente.In order for the background thread to access the Content property of the Button, the background thread must delegate the work to the Dispatcher associated with the UI thread. Questa operazione viene eseguita usando Invoke o BeginInvoke .This is accomplished by using either Invoke or BeginInvoke. Invoke è sincrono ed BeginInvoke è asincrono.Invoke is synchronous and BeginInvoke is asynchronous. L'operazione viene aggiunta alla coda degli eventi di Dispatcher in corrispondenza dell'oggetto specificato DispatcherPriority .The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
Invoke è un'operazione sincrona. Pertanto, il controllo non tornerà all'oggetto chiamante finché non viene restituito il callback.Invoke is a synchronous operation; therefore, control will not return to the calling object until after the callback returns.
Si applica a
Invoke(DispatcherPriority, TimeSpan, Delegate, Object)
Esegue in modo sincrono il delegato specificato con la priorità e l'argomento specificati sul thread al quale Dispatcher è associato.Executes the specified delegate at the specified priority with the specified argument synchronously on the thread the Dispatcher is associated with.
public:
System::Object ^ Invoke(System::Windows::Threading::DispatcherPriority priority, TimeSpan timeout, Delegate ^ method, System::Object ^ arg);
[System.ComponentModel.Browsable(false)]
public object Invoke (System.Windows.Threading.DispatcherPriority priority, TimeSpan timeout, Delegate method, object arg);
[<System.ComponentModel.Browsable(false)>]
member this.Invoke : System.Windows.Threading.DispatcherPriority * TimeSpan * Delegate * obj -> obj
Public Function Invoke (priority As DispatcherPriority, timeout As TimeSpan, method As Delegate, arg As Object) As Object
Parametri
- priority
- DispatcherPriority
Priorità, relativa alle altre operazioni in sospeso nella Dispatcher coda degli eventi, con cui viene richiamato il metodo specificato.The priority, relative to the other pending operations in the Dispatcher event queue, with which the specified method is invoked.
- timeout
- TimeSpan
Tempo massimo di attesa per l'avvio dell'operazione.The maximum amount of time to wait for the operation to start. Una volta avviata, l'operazione verrà completata prima che questo metodo venga restituito.Once the operation has started, it will complete before this method returns. Per specificare un'attesa infinita, usare un valore pari a-1.To specify an infinite wait, use a value of -1. In una chiamata allo stesso thread, qualsiasi altro valore negativo viene convertito in-1, ottenendo un'attesa infinita.In a same-thread call, any other negative value is converted to -1, resulting in an infinite wait. In una chiamata cross-thread, qualsiasi altro valore negativo genera un'eccezione ArgumentOutOfRangeException .In a cross-thread call, any other negative value throws an ArgumentOutOfRangeException.
- method
- Delegate
Delegato a un metodo che accetta più argomenti, inserito nella coda degli eventi di Dispatcher.A delegate to a method that takes multiple arguments, which is pushed onto the Dispatcher event queue.
- arg
- Object
Oggetto da passare come argomento al metodo specificato.An object to pass as an argument to the given method. Se non sono richiesti argomenti, può corrispondere a null
.This can be null
if no arguments are needed.
Restituisce
Valore restituito dal delegato richiamato oppure null
se il delegato non restituisce alcun valore.The return value from the delegate being invoked or null
if the delegate has no return value.
- Attributi
Eccezioni
priority
non è una priorità valida.priority
is not a valid priority.
method
è null
.method
is null
.
Commenti
arg
può essere null
se non è necessario un argomentoarg
can be null
if an argument is not needed
In WPF solo il thread che ha creato un DispatcherObject può accedere a tale oggetto.In WPF, only the thread that created a DispatcherObject may access that object. Ad esempio, un thread in background che viene girato dal thread principale dell'interfaccia utente non può aggiornare il contenuto di un oggetto Button creato nel thread UI.For example, a background thread that is spun off from the main UI thread cannot update the contents of a Button that was created on the UI thread. Affinché il thread in background acceda alla proprietà Content di Button , il thread in background deve delegare il lavoro all'oggetto Dispatcher associato al thread dell'interfaccia utente.In order for the background thread to access the Content property of the Button, the background thread must delegate the work to the Dispatcher associated with the UI thread. Questa operazione viene eseguita usando Invoke o BeginInvoke .This is accomplished by using either Invoke or BeginInvoke. Invoke è sincrono ed BeginInvoke è asincrono.Invoke is synchronous and BeginInvoke is asynchronous. L'operazione viene aggiunta alla coda degli eventi di Dispatcher in corrispondenza dell'oggetto specificato DispatcherPriority .The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
Invoke è un'operazione sincrona. Pertanto, il controllo non tornerà all'oggetto chiamante finché non viene restituito il callback.Invoke is a synchronous operation; therefore, control will not return to the calling object until after the callback returns.
Si applica a
Invoke(DispatcherPriority, Delegate, Object, Object[])
Esegue in modo sincrono il delegato specificato con la priorità e gli argomenti specificati sul thread al quale Dispatcher è associato.Executes the specified delegate at the specified priority with the specified arguments synchronously on the thread the Dispatcher is associated with.
public:
System::Object ^ Invoke(System::Windows::Threading::DispatcherPriority priority, Delegate ^ method, System::Object ^ arg, ... cli::array <System::Object ^> ^ args);
[System.ComponentModel.Browsable(false)]
public object Invoke (System.Windows.Threading.DispatcherPriority priority, Delegate method, object arg, params object[] args);
[<System.ComponentModel.Browsable(false)>]
member this.Invoke : System.Windows.Threading.DispatcherPriority * Delegate * obj * obj[] -> obj
Public Function Invoke (priority As DispatcherPriority, method As Delegate, arg As Object, ParamArray args As Object()) As Object
Parametri
- priority
- DispatcherPriority
Priorità, relativa alle altre operazioni in sospeso nella Dispatcher coda degli eventi, con cui viene richiamato il metodo specificato.The priority, relative to the other pending operations in the Dispatcher event queue, with which the specified method is invoked.
- method
- Delegate
Delegato a un metodo che accetta più argomenti, inserito nella coda degli eventi di Dispatcher.A delegate to a method that takes multiple arguments, which is pushed onto the Dispatcher event queue.
- arg
- Object
Oggetto da passare come argomento al metodo specificato.An object to pass as an argument to the given method.
- args
- Object[]
Matrice di oggetti da passare come argomenti al metodo specificato.An array of objects to pass as arguments to the given method.
Restituisce
Valore restituito dal delegato richiamato oppure null
se il delegato non restituisce alcun valore.The return value from the delegate being invoked or null
if the delegate has no return value.
- Attributi
Eccezioni
priority
non è una priorità valida.priority
is not a valid priority.
method
è null
.method
is null
.
Commenti
arg
può essere null
se non è necessario un argomentoarg
can be null
if an argument is not needed
In WPF solo il thread che ha creato un DispatcherObject può accedere a tale oggetto.In WPF, only the thread that created a DispatcherObject may access that object. Ad esempio, un thread in background che viene girato dal thread principale dell'interfaccia utente non può aggiornare il contenuto di un oggetto Button creato nel thread UI.For example, a background thread that is spun off from the main UI thread cannot update the contents of a Button that was created on the UI thread. Affinché il thread in background acceda alla proprietà Content di Button , il thread in background deve delegare il lavoro all'oggetto Dispatcher associato al thread dell'interfaccia utente.In order for the background thread to access the Content property of the Button, the background thread must delegate the work to the Dispatcher associated with the UI thread. Questa operazione viene eseguita usando Invoke o BeginInvoke .This is accomplished by using either Invoke or BeginInvoke. Invoke è sincrono ed BeginInvoke è asincrono.Invoke is synchronous and BeginInvoke is asynchronous. L'operazione viene aggiunta alla coda degli eventi di Dispatcher in corrispondenza dell'oggetto specificato DispatcherPriority .The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
Invoke è un'operazione sincrona. Pertanto, il controllo non tornerà all'oggetto chiamante finché non viene restituito il callback.Invoke is a synchronous operation; therefore, control will not return to the calling object until after the callback returns.
Si applica a
Invoke(Action, DispatcherPriority, CancellationToken, TimeSpan)
Esegue in modo sincrono il Action specificato con la priorità specificata sul thread al quale Dispatcher è associato.Executes the specified Action synchronously at the specified priority on the thread the Dispatcher is associated with.
public:
void Invoke(Action ^ callback, System::Windows::Threading::DispatcherPriority priority, System::Threading::CancellationToken cancellationToken, TimeSpan timeout);
public void Invoke (Action callback, System.Windows.Threading.DispatcherPriority priority, System.Threading.CancellationToken cancellationToken, TimeSpan timeout);
member this.Invoke : Action * System.Windows.Threading.DispatcherPriority * System.Threading.CancellationToken * TimeSpan -> unit
Public Sub Invoke (callback As Action, priority As DispatcherPriority, cancellationToken As CancellationToken, timeout As TimeSpan)
Parametri
- callback
- Action
Delegato dell'azione da richiamare tramite il dispatcher.An Action delegate to invoke through the dispatcher.
- priority
- DispatcherPriority
Priorità che determina l'ordine in cui viene richiamato il callback specificato rispetto alle altre operazioni in sospeso in Dispatcher .The priority that determines the order in which the specified callback is invoked relative to the other pending operations in the Dispatcher.
- cancellationToken
- CancellationToken
Oggetto che indica se annullare l'azione.An object that indicates whether to cancel the action.
- timeout
- TimeSpan
Tempo massimo di attesa per l'avvio dell'operazione.The maximum amount of time to wait for the operation to start. Una volta avviata, l'operazione verrà completata prima che questo metodo venga restituito.Once the operation has started, it will complete before this method returns. Per specificare un'attesa infinita, usare un valore pari a-1.To specify an infinite wait, use a value of -1. In una chiamata allo stesso thread, qualsiasi altro valore negativo viene convertito in-1, ottenendo un'attesa infinita.In a same-thread call, any other negative value is converted to -1, resulting in an infinite wait. In una chiamata cross-thread, qualsiasi altro valore negativo genera un'eccezione ArgumentOutOfRangeException .In a cross-thread call, any other negative value throws an ArgumentOutOfRangeException.
Eccezioni
callback
è null
.callback
is null
.
timeout
è un numero negativo diverso da-1 e questo metodo è stato richiamato tra thread.timeout
is a negative number other than -1, and this method was invoked across threads.
priority
non è una priorità valida.priority
is not a valid priority.
Si applica a
Invoke(DispatcherPriority, TimeSpan, Delegate)
Esegue in modo sincrono il delegato specificato con la priorità e il valore di timeout specificati sul thread al quale Dispatcher è associato.Executes the specified delegate synchronously at the specified priority and with the specified time-out value on the thread the Dispatcher was created.
public:
System::Object ^ Invoke(System::Windows::Threading::DispatcherPriority priority, TimeSpan timeout, Delegate ^ method);
[System.ComponentModel.Browsable(false)]
public object Invoke (System.Windows.Threading.DispatcherPriority priority, TimeSpan timeout, Delegate method);
[<System.ComponentModel.Browsable(false)>]
member this.Invoke : System.Windows.Threading.DispatcherPriority * TimeSpan * Delegate -> obj
Public Function Invoke (priority As DispatcherPriority, timeout As TimeSpan, method As Delegate) As Object
Parametri
- priority
- DispatcherPriority
Priorità, relativa alle altre operazioni in sospeso nella Dispatcher coda degli eventi, con cui viene richiamato il metodo specificato.The priority, relative to the other pending operations in the Dispatcher event queue, with which the specified method is invoked.
- timeout
- TimeSpan
Tempo massimo di attesa per l'avvio dell'operazione.The maximum amount of time to wait for the operation to start. Una volta avviata, l'operazione verrà completata prima che questo metodo venga restituito.Once the operation has started, it will complete before this method returns. Per specificare un'attesa infinita, usare un valore pari a-1.To specify an infinite wait, use a value of -1. In una chiamata allo stesso thread, qualsiasi altro valore negativo viene convertito in-1, ottenendo un'attesa infinita.In a same-thread call, any other negative value is converted to -1, resulting in an infinite wait. In una chiamata cross-thread, qualsiasi altro valore negativo genera un'eccezione ArgumentOutOfRangeException .In a cross-thread call, any other negative value throws an ArgumentOutOfRangeException.
- method
- Delegate
Delegato a un metodo che non accetta argomenti, inserito nella coda degli eventi di Dispatcher.The delegate to a method that takes no arguments, which is pushed onto the Dispatcher event queue.
Restituisce
Valore restituito dal delegato richiamato oppure null
se il delegato non restituisce alcun valore.The return value from the delegate being invoked or null
if the delegate has no return value.
- Attributi
Eccezioni
method
è null
.method
is null
.
timeout
è un numero negativo diverso da-1 e questo metodo è stato richiamato tra thread.timeout
is a negative number other than -1, and this method was invoked across threads.
priority
non è una priorità valida.priority
is not a valid priority.
Commenti
In WPF solo il thread che ha creato un DispatcherObject può accedere a tale oggetto.In WPF, only the thread that created a DispatcherObject may access that object. Ad esempio, un thread in background che viene girato dal thread principale dell'interfaccia utente non può aggiornare il contenuto di un oggetto Button creato nel thread UI.For example, a background thread that is spun off from the main UI thread cannot update the contents of a Button that was created on the UI thread. Affinché il thread in background acceda alla proprietà Content di Button , il thread in background deve delegare il lavoro all'oggetto Dispatcher associato al thread dell'interfaccia utente.In order for the background thread to access the Content property of the Button, the background thread must delegate the work to the Dispatcher associated with the UI thread. Questa operazione viene eseguita usando Invoke o BeginInvoke .This is accomplished by using either Invoke or BeginInvoke. Invoke è sincrono ed BeginInvoke è asincrono.Invoke is synchronous and BeginInvoke is asynchronous. L'operazione viene aggiunta alla coda degli eventi di Dispatcher in corrispondenza dell'oggetto specificato DispatcherPriority .The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
Invoke è un'operazione sincrona. Pertanto, il controllo non tornerà all'oggetto chiamante finché non viene restituito il callback.Invoke is a synchronous operation; therefore, control will not return to the calling object until after the callback returns.
Si applica a
Invoke(DispatcherPriority, Delegate, Object)
Esegue in modo sincrono il delegato specificato con la priorità e l'argomento specificati sul thread al quale Dispatcher è associato.Executes the specified delegate at the specified priority with the specified argument synchronously on the thread the Dispatcher is associated with.
public:
System::Object ^ Invoke(System::Windows::Threading::DispatcherPriority priority, Delegate ^ method, System::Object ^ arg);
[System.ComponentModel.Browsable(false)]
public object Invoke (System.Windows.Threading.DispatcherPriority priority, Delegate method, object arg);
[<System.ComponentModel.Browsable(false)>]
member this.Invoke : System.Windows.Threading.DispatcherPriority * Delegate * obj -> obj
Public Function Invoke (priority As DispatcherPriority, method As Delegate, arg As Object) As Object
Parametri
- priority
- DispatcherPriority
Priorità, relativa alle altre operazioni in sospeso nella Dispatcher coda degli eventi, con cui viene richiamato il metodo specificato.The priority, relative to the other pending operations in the Dispatcher event queue, with which the specified method is invoked.
- method
- Delegate
Delegato a un metodo che accetta un argomento, inserito nella coda degli eventi di Dispatcher.A delegate to a method that takes one argument, which is pushed onto the Dispatcher event queue.
- arg
- Object
Oggetto da passare come argomento al metodo specificato.An object to pass as an argument to the given method.
Restituisce
Valore restituito dal delegato richiamato oppure null
se il delegato non restituisce alcun valore.The return value from the delegate being invoked or null
if the delegate has no return value.
- Attributi
Eccezioni
priority
non è una priorità valida.priority
is not a valid priority.
method
è null
.method
is null
.
Commenti
arg
può essere null
se non è necessario un argomentoarg
can be null
if an argument is not needed
In WPF solo il thread che ha creato un DispatcherObject può accedere a tale oggetto.In WPF, only the thread that created a DispatcherObject may access that object. Ad esempio, un thread in background che viene girato dal thread principale dell'interfaccia utente non può aggiornare il contenuto di un oggetto Button creato nel thread UI.For example, a background thread that is spun off from the main UI thread cannot update the contents of a Button that was created on the UI thread. Affinché il thread in background acceda alla proprietà Content di Button , il thread in background deve delegare il lavoro all'oggetto Dispatcher associato al thread dell'interfaccia utente.In order for the background thread to access the Content property of the Button, the background thread must delegate the work to the Dispatcher associated with the UI thread. Questa operazione viene eseguita usando Invoke o BeginInvoke .This is accomplished by using either Invoke or BeginInvoke. Invoke è sincrono ed BeginInvoke è asincrono.Invoke is synchronous and BeginInvoke is asynchronous. L'operazione viene aggiunta alla coda degli eventi di Dispatcher in corrispondenza dell'oggetto specificato DispatcherPriority .The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
Invoke è un'operazione sincrona. Pertanto, il controllo non tornerà all'oggetto chiamante finché non viene restituito il callback.Invoke is a synchronous operation; therefore, control will not return to the calling object until after the callback returns.
Si applica a
Invoke(Delegate, TimeSpan, DispatcherPriority, Object[])
Esegue in modo sincrono il delegato specificato entro l'intervallo di tempo designato con la priorità e gli argomenti specificati sul thread al quale Dispatcher è associato.Executes the specified delegate within the designated time span at the specified priority with the specified arguments synchronously on the thread the Dispatcher is associated with.
public:
System::Object ^ Invoke(Delegate ^ method, TimeSpan timeout, System::Windows::Threading::DispatcherPriority priority, ... cli::array <System::Object ^> ^ args);
public object Invoke (Delegate method, TimeSpan timeout, System.Windows.Threading.DispatcherPriority priority, params object[] args);
member this.Invoke : Delegate * TimeSpan * System.Windows.Threading.DispatcherPriority * obj[] -> obj
Public Function Invoke (method As Delegate, timeout As TimeSpan, priority As DispatcherPriority, ParamArray args As Object()) As Object
Parametri
- method
- Delegate
Delegato a un metodo che accetta i parametri specificati in args
, inserito nella coda di eventi Dispatcher.A delegate to a method that takes parameters specified in args
, which is pushed onto the Dispatcher event queue.
- timeout
- TimeSpan
Tempo massimo di attesa per l'avvio dell'operazione.The maximum amount of time to wait for the operation to start. Una volta avviata, l'operazione verrà completata prima che questo metodo venga restituito.Once the operation has started, it will complete before this method returns. Per specificare un'attesa infinita, usare un valore pari a-1.To specify an infinite wait, use a value of -1. In una chiamata allo stesso thread, qualsiasi altro valore negativo viene convertito in-1, ottenendo un'attesa infinita.In a same-thread call, any other negative value is converted to -1, resulting in an infinite wait. In una chiamata cross-thread, qualsiasi altro valore negativo genera un'eccezione ArgumentOutOfRangeException .In a cross-thread call, any other negative value throws an ArgumentOutOfRangeException.
- priority
- DispatcherPriority
Priorità, relativa alle altre operazioni in sospeso nella Dispatcher coda degli eventi, con cui viene richiamato il metodo specificato.The priority, relative to the other pending operations in the Dispatcher event queue, with which the specified method is invoked.
- args
- Object[]
Matrice di oggetti da passare come argomenti al metodo specificato.An array of objects to pass as arguments to the given method. Può essere null
.Can be null
.
Restituisce
Valore restituito dal delegato richiamato oppure null
se il delegato non restituisce alcun valore.The return value from the delegate being invoked or null
if the delegate has no return value.
Eccezioni
method
è null
.method
is null
.
timeout
è un numero negativo diverso da-1 e questo metodo è stato richiamato tra thread.timeout
is a negative number other than -1, and this method was invoked across threads.
priority
non è una priorità valida.priority
is not a valid priority.
Commenti
In WPF solo il thread che ha creato un DispatcherObject può accedere a tale oggetto.In WPF, only the thread that created a DispatcherObject may access that object. Ad esempio, un thread in background che viene girato dal thread principale dell'interfaccia utente non può aggiornare il contenuto di un oggetto Button creato nel thread UI.For example, a background thread that is spun off from the main UI thread cannot update the contents of a Button that was created on the UI thread. Affinché il thread in background acceda alla proprietà Content di Button , il thread in background deve delegare il lavoro all'oggetto Dispatcher associato al thread dell'interfaccia utente.In order for the background thread to access the Content property of the Button, the background thread must delegate the work to the Dispatcher associated with the UI thread. Questa operazione viene eseguita usando Invoke o BeginInvoke .This is accomplished by using either Invoke or BeginInvoke. Invoke è sincrono ed BeginInvoke è asincrono.Invoke is synchronous and BeginInvoke is asynchronous. L'operazione viene aggiunta alla coda degli eventi di Dispatcher in corrispondenza dell'oggetto specificato DispatcherPriority .The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
Invoke è un'operazione sincrona. Pertanto, il controllo non tornerà all'oggetto chiamante finché non viene restituito il callback.Invoke is a synchronous operation; therefore, control will not return to the calling object until after the callback returns.
Si applica a
Invoke(Delegate, TimeSpan, Object[])
Esegue in modo sincrono il delegato specificato entro l'intervallo di tempo designato con la priorità e gli argomenti specificati sul thread al quale Dispatcher è associato.Executes the specified delegate within the designated time span at the specified priority with the specified arguments synchronously on the thread the Dispatcher is associated with.
public:
System::Object ^ Invoke(Delegate ^ method, TimeSpan timeout, ... cli::array <System::Object ^> ^ args);
public object Invoke (Delegate method, TimeSpan timeout, params object[] args);
member this.Invoke : Delegate * TimeSpan * obj[] -> obj
Public Function Invoke (method As Delegate, timeout As TimeSpan, ParamArray args As Object()) As Object
Parametri
- method
- Delegate
Delegato a un metodo che accetta i parametri specificati in args
, inserito nella coda di eventi Dispatcher.A delegate to a method that takes parameters specified in args
, which is pushed onto the Dispatcher event queue.
- timeout
- TimeSpan
Tempo massimo di attesa per l'avvio dell'operazione.The maximum amount of time to wait for the operation to start. Tuttavia, una volta avviata, l'operazione verrà completata prima che questo metodo venga restituito.However, once the operation starts, it will complete before this method returns. Per specificare un'attesa infinita, usare un valore pari a-1.To specify an infinite wait, use a value of -1. In una chiamata allo stesso thread, qualsiasi altro valore negativo viene convertito in-1, ottenendo un'attesa infinita.In a same-thread call, any other negative value is converted to -1, resulting in an infinite wait. In una chiamata cross-thread, qualsiasi altro valore negativo genera un'eccezione ArgumentOutOfRangeException .In a cross-thread call, any other negative value throws an ArgumentOutOfRangeException.
- args
- Object[]
Matrice di oggetti da passare come argomenti al metodo specificato.An array of objects to pass as arguments to the given method. Può essere null
se non è necessario alcun argomento.Can be null
if no arguments are needed.
Restituisce
Valore restituito dal delegato richiamato oppure null
se il delegato non restituisce alcun valore.The return value from the delegate being invoked or null
if the delegate has no return value.
Eccezioni
method
è null
.method
is null
.
timeout
è un numero negativo diverso da-1 e si sta richiamando tra thread.timeout
is a negative number other than -1, and you're invoking across threads.
Commenti
In WPF solo il thread che ha creato un DispatcherObject può accedere a tale oggetto.In WPF, only the thread that created a DispatcherObject may access that object. Ad esempio, un thread in background che viene girato dal thread principale dell'interfaccia utente non può aggiornare il contenuto di un oggetto Button creato nel thread UI.For example, a background thread that is spun off from the main UI thread cannot update the contents of a Button that was created on the UI thread. Affinché il thread in background acceda alla proprietà Content di Button , il thread in background deve delegare il lavoro all'oggetto Dispatcher associato al thread dell'interfaccia utente.In order for the background thread to access the Content property of the Button, the background thread must delegate the work to the Dispatcher associated with the UI thread. Questa operazione viene eseguita usando Invoke o BeginInvoke .This is accomplished by using either Invoke or BeginInvoke. Invoke è sincrono ed BeginInvoke è asincrono.Invoke is synchronous and BeginInvoke is asynchronous. L'operazione viene aggiunta alla coda degli eventi di Dispatcher in corrispondenza dell'oggetto specificato DispatcherPriority .The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
Invoke è un'operazione sincrona. Pertanto, il controllo non tornerà all'oggetto chiamante finché non viene restituito il callback.Invoke is a synchronous operation; therefore, control won't return to the calling object until after the callback returns.
Si applica a
Invoke(Action, DispatcherPriority, CancellationToken)
Esegue in modo sincrono il Action specificato con la priorità specificata sul thread al quale Dispatcher è associato.Executes the specified Action synchronously at the specified priority on the thread the Dispatcher is associated with.
public:
void Invoke(Action ^ callback, System::Windows::Threading::DispatcherPriority priority, System::Threading::CancellationToken cancellationToken);
public void Invoke (Action callback, System.Windows.Threading.DispatcherPriority priority, System.Threading.CancellationToken cancellationToken);
member this.Invoke : Action * System.Windows.Threading.DispatcherPriority * System.Threading.CancellationToken -> unit
Public Sub Invoke (callback As Action, priority As DispatcherPriority, cancellationToken As CancellationToken)
Parametri
- callback
- Action
Un delegato da richiamare tramite il dispatcher.A delegate to invoke through the dispatcher.
- priority
- DispatcherPriority
Priorità che determina l'ordine in cui viene richiamato il callback specificato rispetto alle altre operazioni in sospeso in Dispatcher .The priority that determines the order in which the specified callback is invoked relative to the other pending operations in the Dispatcher.
- cancellationToken
- CancellationToken
Oggetto che indica se annullare l'azione.An object that indicates whether to cancel the action.
Si applica a
Invoke(DispatcherPriority, Delegate)
Esegue in modo sincrono il delegato specificato con la priorità specificata sul thread al quale Dispatcher è associato.Executes the specified delegate synchronously at the specified priority on the thread that the Dispatcher is associated with.
public:
System::Object ^ Invoke(System::Windows::Threading::DispatcherPriority priority, Delegate ^ method);
[System.ComponentModel.Browsable(false)]
public object Invoke (System.Windows.Threading.DispatcherPriority priority, Delegate method);
[<System.ComponentModel.Browsable(false)>]
member this.Invoke : System.Windows.Threading.DispatcherPriority * Delegate -> obj
Public Function Invoke (priority As DispatcherPriority, method As Delegate) As Object
Parametri
- priority
- DispatcherPriority
Priorità con cui viene richiamato il metodo specificato rispetto alle altre operazioni in sospeso nella Dispatcher coda degli eventi.The priority with which the specified method is invoked, relative to the other pending operations in the Dispatcher event queue.
- method
- Delegate
Delegato a un metodo che non accetta argomenti, inserito nella coda degli eventi di Dispatcher.A delegate to a method that takes no arguments, which is pushed onto the Dispatcher event queue.
Restituisce
Valore restituito dal delegato richiamato oppure null
se il delegato non restituisce alcun valore.The return value from the delegate being invoked or null
if the delegate has no return value.
- Attributi
Eccezioni
priority
non è una priorità valida.priority
is not a valid priority.
method
è null
.method
is null
.
Esempio
Nell'esempio seguente viene inserito un delegato su un oggetto Dispatcher in Normal utilizzando Invoke .The following example places a delegate onto a Dispatcher at Normal using Invoke.
// Places the delegate onto the UI Thread's Dispatcher
private void timer_Elapsed(object sender, ElapsedEventArgs e)
{
// Place delegate on the Dispatcher.
this.Dispatcher.Invoke(DispatcherPriority.Normal,
new TimerDispatcherDelegate(TimerWorkItem));
}
' Places the delegate onto the UI Thread's Dispatcher
Private Sub timer_Elapsed(ByVal sender As Object, ByVal e As ElapsedEventArgs)
' Place delegate on the Dispatcher.
Me.Dispatcher.Invoke(DispatcherPriority.Normal, New TimerDispatcherDelegate(AddressOf TimerWorkItem))
End Sub
Commenti
In WPF solo il thread che ha creato un DispatcherObject può accedere a tale oggetto.In WPF, only the thread that created a DispatcherObject may access that object. Ad esempio, un thread in background che viene girato dal thread principale dell'interfaccia utente non può aggiornare il contenuto di un oggetto Button creato nel thread UI.For example, a background thread that is spun off from the main UI thread cannot update the contents of a Button that was created on the UI thread. Affinché il thread in background acceda alla proprietà Content di Button , il thread in background deve delegare il lavoro all'oggetto Dispatcher associato al thread dell'interfaccia utente.In order for the background thread to access the Content property of the Button, the background thread must delegate the work to the Dispatcher associated with the UI thread. Questa operazione viene eseguita usando Invoke o BeginInvoke .This is accomplished by using either Invoke or BeginInvoke. Invoke è sincrono ed BeginInvoke è asincrono.Invoke is synchronous and BeginInvoke is asynchronous. L'operazione viene aggiunta alla coda degli eventi di Dispatcher in corrispondenza dell'oggetto specificato DispatcherPriority .The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
Invoke è un'operazione sincrona. Pertanto, il controllo non tornerà all'oggetto chiamante finché non viene restituito il callback.Invoke is a synchronous operation; therefore, control will not return to the calling object until after the callback returns.
Si applica a
Invoke(Delegate, Object[])
Esegue in modo asincrono il delegato specificato con gli argomenti specificati sul thread al quale Dispatcher è associato.Executes the specified delegate with the specified arguments synchronously on the thread the Dispatcher is associated with.
public:
System::Object ^ Invoke(Delegate ^ method, ... cli::array <System::Object ^> ^ args);
public object Invoke (Delegate method, params object[] args);
member this.Invoke : Delegate * obj[] -> obj
Public Function Invoke (method As Delegate, ParamArray args As Object()) As Object
Parametri
- method
- Delegate
Delegato a un metodo che accetta i parametri specificati in args
, inserito nella coda di eventi Dispatcher.A delegate to a method that takes parameters specified in args
, which is pushed onto the Dispatcher event queue.
- args
- Object[]
Matrice di oggetti da passare come argomenti al metodo specificato.An array of objects to pass as arguments to the given method. Può essere null
.Can be null
.
Restituisce
Valore restituito dal delegato richiamato oppure null
se il delegato non restituisce alcun valore.The return value from the delegate being invoked or null
if the delegate has no return value.
Commenti
In WPF solo il thread che ha creato un DispatcherObject può accedere a tale oggetto.In WPF, only the thread that created a DispatcherObject may access that object. Ad esempio, un thread in background che viene girato dal thread principale dell'interfaccia utente non può aggiornare il contenuto di un oggetto Button creato nel thread UI.For example, a background thread that is spun off from the main UI thread cannot update the contents of a Button that was created on the UI thread. Affinché il thread in background acceda alla proprietà Content di Button , il thread in background deve delegare il lavoro all'oggetto Dispatcher associato al thread dell'interfaccia utente.In order for the background thread to access the Content property of the Button, the background thread must delegate the work to the Dispatcher associated with the UI thread. Questa operazione viene eseguita usando Invoke o BeginInvoke .This is accomplished by using either Invoke or BeginInvoke. Invoke è sincrono ed BeginInvoke è asincrono.Invoke is synchronous and BeginInvoke is asynchronous. L'operazione viene aggiunta alla coda degli eventi di Dispatcher in corrispondenza dell'oggetto specificato DispatcherPriority .The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
Invoke è un'operazione sincrona. Pertanto, il controllo non tornerà all'oggetto chiamante finché non viene restituito il callback.Invoke is a synchronous operation; therefore, control will not return to the calling object until after the callback returns.
Si applica a
Invoke(Action, DispatcherPriority)
Esegue in modo sincrono il Action specificato con la priorità specificata sul thread al quale Dispatcher è associato.Executes the specified Action synchronously at the specified priority on the thread the Dispatcher is associated with.
public:
void Invoke(Action ^ callback, System::Windows::Threading::DispatcherPriority priority);
public void Invoke (Action callback, System.Windows.Threading.DispatcherPriority priority);
member this.Invoke : Action * System.Windows.Threading.DispatcherPriority -> unit
Public Sub Invoke (callback As Action, priority As DispatcherPriority)
Parametri
- callback
- Action
Un delegato da richiamare tramite il dispatcher.A delegate to invoke through the dispatcher.
- priority
- DispatcherPriority
Priorità che determina l'ordine in cui viene richiamato il callback specificato rispetto alle altre operazioni in sospeso in Dispatcher .The priority that determines the order in which the specified callback is invoked relative to the other pending operations in the Dispatcher.
Si applica a
Invoke(Action)
Esegue in modo sincrono il Action specificato sul thread al quale Dispatcher è associato.Executes the specified Action synchronously on the thread the Dispatcher is associated with.
public:
void Invoke(Action ^ callback);
public void Invoke (Action callback);
member this.Invoke : Action -> unit
Public Sub Invoke (callback As Action)
Parametri
- callback
- Action
Un delegato da richiamare tramite il dispatcher.A delegate to invoke through the dispatcher.
Si applica a
Invoke(Delegate, DispatcherPriority, Object[])
Esegue in modo sincrono il delegato specificato con la priorità e gli argomenti specificati sul thread al quale Dispatcher è associato.Executes the specified delegate at the specified priority with the specified arguments synchronously on the thread the Dispatcher is associated with.
public:
System::Object ^ Invoke(Delegate ^ method, System::Windows::Threading::DispatcherPriority priority, ... cli::array <System::Object ^> ^ args);
public object Invoke (Delegate method, System.Windows.Threading.DispatcherPriority priority, params object[] args);
member this.Invoke : Delegate * System.Windows.Threading.DispatcherPriority * obj[] -> obj
Public Function Invoke (method As Delegate, priority As DispatcherPriority, ParamArray args As Object()) As Object
Parametri
- method
- Delegate
Delegato a un metodo che accetta i parametri specificati in args
, inserito nella coda di eventi Dispatcher.A delegate to a method that takes parameters specified in args
, which is pushed onto the Dispatcher event queue.
- priority
- DispatcherPriority
Priorità con cui viene richiamato il metodo specificato rispetto alle altre operazioni in sospeso nella Dispatcher coda degli eventi.The priority with which the specified method is invoked, relative to the other pending operations in the Dispatcher event queue.
- args
- Object[]
Matrice di oggetti da passare come argomenti al metodo specificato.An array of objects to pass as arguments to the given method. Può essere null
.Can be null
.
Restituisce
Valore restituito dal delegato richiamato oppure null
se il delegato non restituisce alcun valore.The return value from the delegate being invoked or null
if the delegate has no return value.
Commenti
In WPF solo il thread che ha creato un DispatcherObject può accedere a tale oggetto.In WPF, only the thread that created a DispatcherObject may access that object. Ad esempio, un thread in background che viene girato dal thread principale dell'interfaccia utente non può aggiornare il contenuto di un oggetto Button creato nel thread UI.For example, a background thread that is spun off from the main UI thread cannot update the contents of a Button that was created on the UI thread. Affinché il thread in background acceda alla proprietà Content di Button , il thread in background deve delegare il lavoro all'oggetto Dispatcher associato al thread dell'interfaccia utente.In order for the background thread to access the Content property of the Button, the background thread must delegate the work to the Dispatcher associated with the UI thread. Questa operazione viene eseguita usando Invoke o BeginInvoke .This is accomplished by using either Invoke or BeginInvoke. Invoke è sincrono ed BeginInvoke è asincrono.Invoke is synchronous and BeginInvoke is asynchronous. L'operazione viene aggiunta alla coda degli eventi di Dispatcher in corrispondenza dell'oggetto specificato DispatcherPriority .The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
Invoke è un'operazione sincrona. Pertanto, il controllo non tornerà all'oggetto chiamante finché non viene restituito il callback.Invoke is a synchronous operation; therefore, control will not return to the calling object until after the callback returns.
Si applica a
Invoke<TResult>(Func<TResult>)
Esegue in modo sincrono il Func<TResult> specificato sul thread al quale Dispatcher è associato.Executes the specified Func<TResult> synchronously on the thread the Dispatcher is associated with.
public:
generic <typename TResult>
TResult Invoke(Func<TResult> ^ callback);
public TResult Invoke<TResult> (Func<TResult> callback);
member this.Invoke : Func<'Result> -> 'Result
Public Function Invoke(Of TResult) (callback As Func(Of TResult)) As TResult
Parametri di tipo
- TResult
Il tipo del valore restituito del delegato specificato.The return value type of the specified delegate.
Parametri
- callback
- Func<TResult>
Un delegato da richiamare tramite il dispatcher.A delegate to invoke through the dispatcher.
Restituisce
- TResult
Valore restituito da callback
.The value returned by callback
.
Si applica a
Invoke<TResult>(Func<TResult>, DispatcherPriority)
Esegue in modo sincrono il Func<TResult> specificato con la priorità specificata sul thread al quale Dispatcher è associato.Executes the specified Func<TResult> synchronously at the specified priority on the thread the Dispatcher is associated with.
public:
generic <typename TResult>
TResult Invoke(Func<TResult> ^ callback, System::Windows::Threading::DispatcherPriority priority);
public TResult Invoke<TResult> (Func<TResult> callback, System.Windows.Threading.DispatcherPriority priority);
member this.Invoke : Func<'Result> * System.Windows.Threading.DispatcherPriority -> 'Result
Public Function Invoke(Of TResult) (callback As Func(Of TResult), priority As DispatcherPriority) As TResult
Parametri di tipo
- TResult
Il tipo del valore restituito del delegato specificato.The return value type of the specified delegate.
Parametri
- callback
- Func<TResult>
Un delegato da richiamare tramite il dispatcher.A delegate to invoke through the dispatcher.
- priority
- DispatcherPriority
Priorità che determina l'ordine in cui viene richiamato il callback specificato rispetto alle altre operazioni in sospeso in Dispatcher .The priority that determines the order in which the specified callback is invoked relative to the other pending operations in the Dispatcher.
Restituisce
- TResult
Valore restituito da callback
.The value returned by callback
.
Si applica a
Invoke<TResult>(Func<TResult>, DispatcherPriority, CancellationToken)
Esegue in modo sincrono il Func<TResult> specificato con la priorità specificata sul thread al quale Dispatcher è associato.Executes the specified Func<TResult> synchronously at the specified priority on the thread the Dispatcher is associated with.
public:
generic <typename TResult>
TResult Invoke(Func<TResult> ^ callback, System::Windows::Threading::DispatcherPriority priority, System::Threading::CancellationToken cancellationToken);
public TResult Invoke<TResult> (Func<TResult> callback, System.Windows.Threading.DispatcherPriority priority, System.Threading.CancellationToken cancellationToken);
member this.Invoke : Func<'Result> * System.Windows.Threading.DispatcherPriority * System.Threading.CancellationToken -> 'Result
Public Function Invoke(Of TResult) (callback As Func(Of TResult), priority As DispatcherPriority, cancellationToken As CancellationToken) As TResult
Parametri di tipo
- TResult
Il tipo del valore restituito del delegato specificato.The return value type of the specified delegate.
Parametri
- callback
- Func<TResult>
Un delegato da richiamare tramite il dispatcher.A delegate to invoke through the dispatcher.
- priority
- DispatcherPriority
Priorità che determina l'ordine in cui viene richiamato il callback specificato rispetto alle altre operazioni in sospeso in Dispatcher .The priority that determines the order in which the specified callback is invoked relative to the other pending operations in the Dispatcher.
- cancellationToken
- CancellationToken
Oggetto che indica se annullare l'operazione.An object that indicates whether to cancel the operation.
Restituisce
- TResult
Valore restituito da callback
.The value returned by callback
.
Si applica a
Invoke<TResult>(Func<TResult>, DispatcherPriority, CancellationToken, TimeSpan)
Esegue in modo sincrono il Func<TResult> specificato con la priorità specificata sul thread al quale Dispatcher è associato.Executes the specified Func<TResult> synchronously at the specified priority on the thread the Dispatcher is associated with.
public:
generic <typename TResult>
TResult Invoke(Func<TResult> ^ callback, System::Windows::Threading::DispatcherPriority priority, System::Threading::CancellationToken cancellationToken, TimeSpan timeout);
public TResult Invoke<TResult> (Func<TResult> callback, System.Windows.Threading.DispatcherPriority priority, System.Threading.CancellationToken cancellationToken, TimeSpan timeout);
member this.Invoke : Func<'Result> * System.Windows.Threading.DispatcherPriority * System.Threading.CancellationToken * TimeSpan -> 'Result
Public Function Invoke(Of TResult) (callback As Func(Of TResult), priority As DispatcherPriority, cancellationToken As CancellationToken, timeout As TimeSpan) As TResult
Parametri di tipo
- TResult
Il tipo del valore restituito del delegato specificato.The return value type of the specified delegate.
Parametri
- callback
- Func<TResult>
Un delegato da richiamare tramite il dispatcher.A delegate to invoke through the dispatcher.
- priority
- DispatcherPriority
Priorità che determina l'ordine in cui viene richiamato il callback specificato rispetto alle altre operazioni in sospeso in Dispatcher .The priority that determines the order in which the specified callback is invoked relative to the other pending operations in the Dispatcher.
- cancellationToken
- CancellationToken
Oggetto che indica se annullare l'operazione.An object that indicates whether to cancel the operation.
- timeout
- TimeSpan
Tempo massimo di attesa per l'avvio dell'operazione.The maximum amount of time to wait for the operation to start. Una volta avviata, l'operazione verrà completata prima che questo metodo venga restituito.Once the operation has started, it will complete before this method returns. Per specificare un'attesa infinita, usare un valore pari a-1.To specify an infinite wait, use a value of -1. In una chiamata allo stesso thread, qualsiasi altro valore negativo viene convertito in-1, ottenendo un'attesa infinita.In a same-thread call, any other negative value is converted to -1, resulting in an infinite wait. In una chiamata cross-thread, qualsiasi altro valore negativo genera un'eccezione ArgumentOutOfRangeException .In a cross-thread call, any other negative value throws an ArgumentOutOfRangeException.
Restituisce
- TResult
Valore restituito da callback
.The value returned by callback
.
Eccezioni
callback
è null
.callback
is null
.
timeout
è un numero negativo diverso da-1 e il metodo è stato richiamato tra thread.timeout
is a negative number other than -1, and the method was invoked across threads.
priority
non è una priorità valida.priority
is not a valid priority.