Dispatcher.Invoke Método
Definição
Executa o delegado especificado de forma síncrona no thread ao qual o Dispatcher está associado.Executes the specified delegate synchronously on the thread the Dispatcher is associated with.
Sobrecargas
Invoke(DispatcherPriority, TimeSpan, Delegate, Object, Object[]) |
Executa o delegado especificado na prioridade especificada com os argumentos especificados de forma síncrona no thread ao qual o Dispatcher está associado.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) |
Executa o delegado especificado na prioridade especificada com o argumentos especificado de forma síncrona no thread ao qual o Dispatcher está associado.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[]) |
Executa o delegado especificado na prioridade especificada com os argumentos especificados de forma síncrona no thread ao qual o Dispatcher está associado.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) |
Executa a Action especificada de forma síncrona na prioridade especificada no thread ao qual o Dispatcher está associado.Executes the specified Action synchronously at the specified priority on the thread the Dispatcher is associated with. |
Invoke(DispatcherPriority, TimeSpan, Delegate) |
Executa o delegado especificado, de forma síncrona, com a prioridade especificada e com o valor de tempo limite especificado no thread em que Dispatcher foi criado.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) |
Executa o delegado especificado na prioridade especificada com o argumentos especificado de forma síncrona no thread ao qual o Dispatcher está associado.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[]) |
Executa o delegado especificado no período designado na prioridade especificada com os argumentos especificados de forma síncrona no thread ao qual o Dispatcher está associado.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[]) |
Executa o delegado especificado no período designado na prioridade especificada com os argumentos especificados de forma síncrona no thread ao qual o Dispatcher está associado.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) |
Executa a Action especificada de forma síncrona na prioridade especificada no thread ao qual o Dispatcher está associado.Executes the specified Action synchronously at the specified priority on the thread the Dispatcher is associated with. |
Invoke(DispatcherPriority, Delegate) |
Executa o delegado especificado de forma síncrona na prioridade especificada no thread ao qual o Dispatcher está associado.Executes the specified delegate synchronously at the specified priority on the thread that the Dispatcher is associated with. |
Invoke(Delegate, Object[]) |
Executa o delegado especificado com os argumentos de forma síncrona no thread ao qual o Dispatcher está associado.Executes the specified delegate with the specified arguments synchronously on the thread the Dispatcher is associated with. |
Invoke(Action, DispatcherPriority) |
Executa a Action especificada de forma síncrona na prioridade especificada no thread ao qual o Dispatcher está associado.Executes the specified Action synchronously at the specified priority on the thread the Dispatcher is associated with. |
Invoke(Action) |
Executa o Action especificado de forma síncrona no thread ao qual o Dispatcher está associado.Executes the specified Action synchronously on the thread the Dispatcher is associated with. |
Invoke(Delegate, DispatcherPriority, Object[]) |
Executa o delegado especificado na prioridade especificada com os argumentos especificados de forma síncrona no thread ao qual o Dispatcher está associado.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>) |
Executa o Func<TResult> especificado de forma síncrona no thread ao qual o Dispatcher está associado.Executes the specified Func<TResult> synchronously on the thread the Dispatcher is associated with. |
Invoke<TResult>(Func<TResult>, DispatcherPriority) |
Executa a Func<TResult> especificada de forma síncrona na prioridade especificada no thread ao qual o Dispatcher está associado.Executes the specified Func<TResult> synchronously at the specified priority on the thread the Dispatcher is associated with. |
Invoke<TResult>(Func<TResult>, DispatcherPriority, CancellationToken) |
Executa a Func<TResult> especificada de forma síncrona na prioridade especificada no thread ao qual o Dispatcher está associado.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) |
Executa a Func<TResult> especificada de forma síncrona na prioridade especificada no thread ao qual o Dispatcher está associado.Executes the specified Func<TResult> synchronously at the specified priority on the thread the Dispatcher is associated with. |
Exemplos
O exemplo a seguir coloca um delegado em uma Dispatcher em Normal usando 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
Comentários
No WPF, somente o thread que criou um DispatcherObject pode acessar esse objeto.In WPF, only the thread that created a DispatcherObject may access that object. Por exemplo, um thread em segundo plano que é rotacionado do thread da interface do usuário principal não pode atualizar o conteúdo de um Button que foi criado no thread da interface do usuário.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. Para que o thread em segundo plano acesse a propriedade content do Button , o thread em segundo plano deve delegar o trabalho para o Dispatcher associado ao thread da interface do usuário.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. Isso é feito usando o Invoke ou o BeginInvoke .This is accomplished by using either Invoke or BeginInvoke. Invoke é síncrono e BeginInvoke é assíncrono.Invoke is synchronous and BeginInvoke is asynchronous. A operação é adicionada à fila de eventos do Dispatcher no especificado DispatcherPriority .The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
Invoke é uma operação síncrona; Portanto, o controle não retornará ao objeto de chamada até que o retorno de chamada seja retornado.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[])
Executa o delegado especificado na prioridade especificada com os argumentos especificados de forma síncrona no thread ao qual o Dispatcher está associado.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
Parâmetros
- priority
- DispatcherPriority
A prioridade, em relação às outras operações pendentes na Dispatcher fila de eventos, com a qual o método especificado é invocado.The priority, relative to the other pending operations in the Dispatcher event queue, with which the specified method is invoked.
- timeout
- TimeSpan
A quantidade máxima de tempo de espera para a operação ser iniciada.The maximum amount of time to wait for the operation to start. Depois que a operação for iniciada, ela será concluída antes que esse método seja retornado.Once the operation has started, it will complete before this method returns. Para especificar uma espera infinita, use um valor de-1.To specify an infinite wait, use a value of -1. Em uma chamada de mesmo thread, qualquer outro valor negativo é convertido em-1, resultando em uma espera infinita.In a same-thread call, any other negative value is converted to -1, resulting in an infinite wait. Em uma chamada entre threads, qualquer outro valor negativo lança um ArgumentOutOfRangeException .In a cross-thread call, any other negative value throws an ArgumentOutOfRangeException.
- method
- Delegate
Um delegado de um método que usa vários argumentos, que é enviado por push para a fila de eventos de Dispatcher.A delegate to a method that takes multiple arguments, which is pushed onto the Dispatcher event queue.
- arg
- Object
Um objeto a ser passado como um argumento para o método especificado.An object to pass as an argument to the specified method.
- args
- Object[]
Uma matriz de objetos a serem passados como argumentos para o método especificado.An array of objects to pass as arguments to the specified method.
Retornos
O valor retornado do delegado que está sendo invocado ou null
, se o delegado não tiver um valor retornado.The return value from the delegate being invoked or null
if the delegate has no return value.
- Atributos
Exceções
priority
não é um DispatcherPriority válido.priority
is not a valid DispatcherPriority.
method
é null
.method
is null
.
timeout
é um número negativo diferente de-1, e esse método foi invocado entre threads.timeout
is a negative number other than -1, and this method was invoked across threads.
Comentários
arg
pode ser null
se um argumento não for necessário.arg
can be null
if an argument is not needed.
No WPF, somente o thread que criou um DispatcherObject pode acessar esse objeto.In WPF, only the thread that created a DispatcherObject may access that object. Por exemplo, um thread em segundo plano que é rotacionado do thread da interface do usuário principal não pode atualizar o conteúdo de um Button que foi criado no thread da interface do usuário.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. Para que o thread em segundo plano acesse a propriedade content do Button , o thread em segundo plano deve delegar o trabalho para o Dispatcher associado ao thread da interface do usuário.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. Isso é feito usando o Invoke ou o BeginInvoke .This is accomplished by using either Invoke or BeginInvoke. Invoke é síncrono e BeginInvoke é assíncrono.Invoke is synchronous and BeginInvoke is asynchronous. A operação é adicionada à fila de eventos do Dispatcher no especificado DispatcherPriority .The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
Invoke é uma operação síncrona; Portanto, o controle não retornará ao objeto de chamada até que o retorno de chamada seja retornado.Invoke is a synchronous operation; therefore, control will not return to the calling object until after the callback returns.
Aplica-se a
Invoke(DispatcherPriority, TimeSpan, Delegate, Object)
Executa o delegado especificado na prioridade especificada com o argumentos especificado de forma síncrona no thread ao qual o Dispatcher está associado.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
Parâmetros
- priority
- DispatcherPriority
A prioridade, em relação às outras operações pendentes na Dispatcher fila de eventos, com a qual o método especificado é invocado.The priority, relative to the other pending operations in the Dispatcher event queue, with which the specified method is invoked.
- timeout
- TimeSpan
A quantidade máxima de tempo de espera para a operação ser iniciada.The maximum amount of time to wait for the operation to start. Depois que a operação for iniciada, ela será concluída antes que esse método seja retornado.Once the operation has started, it will complete before this method returns. Para especificar uma espera infinita, use um valor de-1.To specify an infinite wait, use a value of -1. Em uma chamada de mesmo thread, qualquer outro valor negativo é convertido em-1, resultando em uma espera infinita.In a same-thread call, any other negative value is converted to -1, resulting in an infinite wait. Em uma chamada entre threads, qualquer outro valor negativo lança um ArgumentOutOfRangeException .In a cross-thread call, any other negative value throws an ArgumentOutOfRangeException.
- method
- Delegate
Um delegado de um método que usa vários argumentos, que é enviado por push para a fila de eventos de Dispatcher.A delegate to a method that takes multiple arguments, which is pushed onto the Dispatcher event queue.
- arg
- Object
Um objeto a ser passado como um argumento para o método fornecido.An object to pass as an argument to the given method. Pode ser null
, caso nenhum argumento seja necessário.This can be null
if no arguments are needed.
Retornos
O valor retornado do delegado que está sendo invocado ou null
, se o delegado não tiver um valor retornado.The return value from the delegate being invoked or null
if the delegate has no return value.
- Atributos
Exceções
priority
não é uma prioridade válida.priority
is not a valid priority.
method
é null
.method
is null
.
Comentários
arg
pode ser null
se um argumento não for necessárioarg
can be null
if an argument is not needed
No WPF, somente o thread que criou um DispatcherObject pode acessar esse objeto.In WPF, only the thread that created a DispatcherObject may access that object. Por exemplo, um thread em segundo plano que é rotacionado do thread da interface do usuário principal não pode atualizar o conteúdo de um Button que foi criado no thread da interface do usuário.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. Para que o thread em segundo plano acesse a propriedade content do Button , o thread em segundo plano deve delegar o trabalho para o Dispatcher associado ao thread da interface do usuário.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. Isso é feito usando o Invoke ou o BeginInvoke .This is accomplished by using either Invoke or BeginInvoke. Invoke é síncrono e BeginInvoke é assíncrono.Invoke is synchronous and BeginInvoke is asynchronous. A operação é adicionada à fila de eventos do Dispatcher no especificado DispatcherPriority .The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
Invoke é uma operação síncrona; Portanto, o controle não retornará ao objeto de chamada até que o retorno de chamada seja retornado.Invoke is a synchronous operation; therefore, control will not return to the calling object until after the callback returns.
Aplica-se a
Invoke(DispatcherPriority, Delegate, Object, Object[])
Executa o delegado especificado na prioridade especificada com os argumentos especificados de forma síncrona no thread ao qual o Dispatcher está associado.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
Parâmetros
- priority
- DispatcherPriority
A prioridade, em relação às outras operações pendentes na Dispatcher fila de eventos, com a qual o método especificado é invocado.The priority, relative to the other pending operations in the Dispatcher event queue, with which the specified method is invoked.
- method
- Delegate
Um delegado de um método que usa vários argumentos, que é enviado por push para a fila de eventos de Dispatcher.A delegate to a method that takes multiple arguments, which is pushed onto the Dispatcher event queue.
- arg
- Object
Um objeto a ser passado como um argumento para o método fornecido.An object to pass as an argument to the given method.
- args
- Object[]
Uma matriz de objetos a serem passados como argumentos para o método em questão.An array of objects to pass as arguments to the given method.
Retornos
O valor retornado do delegado que está sendo invocado ou null
, se o delegado não tiver um valor retornado.The return value from the delegate being invoked or null
if the delegate has no return value.
- Atributos
Exceções
priority
não é uma prioridade válida.priority
is not a valid priority.
method
é null
.method
is null
.
Comentários
arg
pode ser null
se um argumento não for necessárioarg
can be null
if an argument is not needed
No WPF, somente o thread que criou um DispatcherObject pode acessar esse objeto.In WPF, only the thread that created a DispatcherObject may access that object. Por exemplo, um thread em segundo plano que é rotacionado do thread da interface do usuário principal não pode atualizar o conteúdo de um Button que foi criado no thread da interface do usuário.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. Para que o thread em segundo plano acesse a propriedade content do Button , o thread em segundo plano deve delegar o trabalho para o Dispatcher associado ao thread da interface do usuário.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. Isso é feito usando o Invoke ou o BeginInvoke .This is accomplished by using either Invoke or BeginInvoke. Invoke é síncrono e BeginInvoke é assíncrono.Invoke is synchronous and BeginInvoke is asynchronous. A operação é adicionada à fila de eventos do Dispatcher no especificado DispatcherPriority .The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
Invoke é uma operação síncrona; Portanto, o controle não retornará ao objeto de chamada até que o retorno de chamada seja retornado.Invoke is a synchronous operation; therefore, control will not return to the calling object until after the callback returns.
Aplica-se a
Invoke(Action, DispatcherPriority, CancellationToken, TimeSpan)
Executa a Action especificada de forma síncrona na prioridade especificada no thread ao qual o Dispatcher está associado.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)
Parâmetros
- callback
- Action
Um delegado de ação a ser invocado por meio do Dispatcher.An Action delegate to invoke through the dispatcher.
- priority
- DispatcherPriority
A prioridade que determina a ordem na qual o retorno de chamada especificado é invocado em relação às outras operações pendentes no 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
Um objeto que indica se a ação deve ser cancelada.An object that indicates whether to cancel the action.
- timeout
- TimeSpan
A quantidade máxima de tempo de espera para a operação ser iniciada.The maximum amount of time to wait for the operation to start. Depois que a operação for iniciada, ela será concluída antes que esse método seja retornado.Once the operation has started, it will complete before this method returns. Para especificar uma espera infinita, use um valor de-1.To specify an infinite wait, use a value of -1. Em uma chamada de mesmo thread, qualquer outro valor negativo é convertido em-1, resultando em uma espera infinita.In a same-thread call, any other negative value is converted to -1, resulting in an infinite wait. Em uma chamada entre threads, qualquer outro valor negativo lança um ArgumentOutOfRangeException .In a cross-thread call, any other negative value throws an ArgumentOutOfRangeException.
Exceções
callback
é null
.callback
is null
.
timeout
é um número negativo diferente de-1, e esse método foi invocado entre threads.timeout
is a negative number other than -1, and this method was invoked across threads.
priority
não é uma prioridade válida.priority
is not a valid priority.
Aplica-se a
Invoke(DispatcherPriority, TimeSpan, Delegate)
Executa o delegado especificado, de forma síncrona, com a prioridade especificada e com o valor de tempo limite especificado no thread em que Dispatcher foi criado.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
Parâmetros
- priority
- DispatcherPriority
A prioridade, em relação às outras operações pendentes na Dispatcher fila de eventos, com a qual o método especificado é invocado.The priority, relative to the other pending operations in the Dispatcher event queue, with which the specified method is invoked.
- timeout
- TimeSpan
A quantidade máxima de tempo de espera para a operação ser iniciada.The maximum amount of time to wait for the operation to start. Depois que a operação for iniciada, ela será concluída antes que esse método seja retornado.Once the operation has started, it will complete before this method returns. Para especificar uma espera infinita, use um valor de-1.To specify an infinite wait, use a value of -1. Em uma chamada de mesmo thread, qualquer outro valor negativo é convertido em-1, resultando em uma espera infinita.In a same-thread call, any other negative value is converted to -1, resulting in an infinite wait. Em uma chamada entre threads, qualquer outro valor negativo lança um ArgumentOutOfRangeException .In a cross-thread call, any other negative value throws an ArgumentOutOfRangeException.
- method
- Delegate
O delegado para um método que não usa argumentos, que é enviado por push para a fila de eventos do Dispatcher.The delegate to a method that takes no arguments, which is pushed onto the Dispatcher event queue.
Retornos
O valor retornado do delegado que está sendo invocado ou null
, se o delegado não tiver um valor retornado.The return value from the delegate being invoked or null
if the delegate has no return value.
- Atributos
Exceções
method
é null
.method
is null
.
timeout
é um número negativo diferente de-1, e esse método foi invocado entre threads.timeout
is a negative number other than -1, and this method was invoked across threads.
priority
não é uma prioridade válida.priority
is not a valid priority.
Comentários
No WPF, somente o thread que criou um DispatcherObject pode acessar esse objeto.In WPF, only the thread that created a DispatcherObject may access that object. Por exemplo, um thread em segundo plano que é rotacionado do thread da interface do usuário principal não pode atualizar o conteúdo de um Button que foi criado no thread da interface do usuário.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. Para que o thread em segundo plano acesse a propriedade content do Button , o thread em segundo plano deve delegar o trabalho para o Dispatcher associado ao thread da interface do usuário.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. Isso é feito usando o Invoke ou o BeginInvoke .This is accomplished by using either Invoke or BeginInvoke. Invoke é síncrono e BeginInvoke é assíncrono.Invoke is synchronous and BeginInvoke is asynchronous. A operação é adicionada à fila de eventos do Dispatcher no especificado DispatcherPriority .The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
Invoke é uma operação síncrona; Portanto, o controle não retornará ao objeto de chamada até que o retorno de chamada seja retornado.Invoke is a synchronous operation; therefore, control will not return to the calling object until after the callback returns.
Aplica-se a
Invoke(DispatcherPriority, Delegate, Object)
Executa o delegado especificado na prioridade especificada com o argumentos especificado de forma síncrona no thread ao qual o Dispatcher está associado.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
Parâmetros
- priority
- DispatcherPriority
A prioridade, em relação às outras operações pendentes na Dispatcher fila de eventos, com a qual o método especificado é invocado.The priority, relative to the other pending operations in the Dispatcher event queue, with which the specified method is invoked.
- method
- Delegate
Um delegado para um método que usa um argumento, que é enviado por push para a fila de eventos do Dispatcher.A delegate to a method that takes one argument, which is pushed onto the Dispatcher event queue.
- arg
- Object
Um objeto a ser passado como um argumento para o método fornecido.An object to pass as an argument to the given method.
Retornos
O valor retornado do delegado que está sendo invocado ou null
, se o delegado não tiver um valor retornado.The return value from the delegate being invoked or null
if the delegate has no return value.
- Atributos
Exceções
priority
não é uma prioridade válida.priority
is not a valid priority.
method
é null
.method
is null
.
Comentários
arg
pode ser null
se um argumento não for necessárioarg
can be null
if an argument is not needed
No WPF, somente o thread que criou um DispatcherObject pode acessar esse objeto.In WPF, only the thread that created a DispatcherObject may access that object. Por exemplo, um thread em segundo plano que é rotacionado do thread da interface do usuário principal não pode atualizar o conteúdo de um Button que foi criado no thread da interface do usuário.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. Para que o thread em segundo plano acesse a propriedade content do Button , o thread em segundo plano deve delegar o trabalho para o Dispatcher associado ao thread da interface do usuário.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. Isso é feito usando o Invoke ou o BeginInvoke .This is accomplished by using either Invoke or BeginInvoke. Invoke é síncrono e BeginInvoke é assíncrono.Invoke is synchronous and BeginInvoke is asynchronous. A operação é adicionada à fila de eventos do Dispatcher no especificado DispatcherPriority .The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
Invoke é uma operação síncrona; Portanto, o controle não retornará ao objeto de chamada até que o retorno de chamada seja retornado.Invoke is a synchronous operation; therefore, control will not return to the calling object until after the callback returns.
Aplica-se a
Invoke(Delegate, TimeSpan, DispatcherPriority, Object[])
Executa o delegado especificado no período designado na prioridade especificada com os argumentos especificados de forma síncrona no thread ao qual o Dispatcher está associado.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
Parâmetros
- method
- Delegate
Um delegado para um método que usa os parâmetros especificados em args
, que é enviado por push para a fila de eventos de Dispatcher.A delegate to a method that takes parameters specified in args
, which is pushed onto the Dispatcher event queue.
- timeout
- TimeSpan
A quantidade máxima de tempo de espera para a operação ser iniciada.The maximum amount of time to wait for the operation to start. Depois que a operação for iniciada, ela será concluída antes que esse método seja retornado.Once the operation has started, it will complete before this method returns. Para especificar uma espera infinita, use um valor de-1.To specify an infinite wait, use a value of -1. Em uma chamada de mesmo thread, qualquer outro valor negativo é convertido em-1, resultando em uma espera infinita.In a same-thread call, any other negative value is converted to -1, resulting in an infinite wait. Em uma chamada entre threads, qualquer outro valor negativo lança um ArgumentOutOfRangeException .In a cross-thread call, any other negative value throws an ArgumentOutOfRangeException.
- priority
- DispatcherPriority
A prioridade, em relação às outras operações pendentes na Dispatcher fila de eventos, com a qual o método especificado é invocado.The priority, relative to the other pending operations in the Dispatcher event queue, with which the specified method is invoked.
- args
- Object[]
Uma matriz de objetos a serem passados como argumentos para o método em questão.An array of objects to pass as arguments to the given method. Pode ser null
.Can be null
.
Retornos
O valor retornado do delegado que está sendo invocado ou null
, se o delegado não tiver um valor retornado.The return value from the delegate being invoked or null
if the delegate has no return value.
Exceções
method
é null
.method
is null
.
timeout
é um número negativo diferente de-1, e esse método foi invocado entre threads.timeout
is a negative number other than -1, and this method was invoked across threads.
priority
não é uma prioridade válida.priority
is not a valid priority.
Comentários
No WPF, somente o thread que criou um DispatcherObject pode acessar esse objeto.In WPF, only the thread that created a DispatcherObject may access that object. Por exemplo, um thread em segundo plano que é rotacionado do thread da interface do usuário principal não pode atualizar o conteúdo de um Button que foi criado no thread da interface do usuário.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. Para que o thread em segundo plano acesse a propriedade content do Button , o thread em segundo plano deve delegar o trabalho para o Dispatcher associado ao thread da interface do usuário.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. Isso é feito usando o Invoke ou o BeginInvoke .This is accomplished by using either Invoke or BeginInvoke. Invoke é síncrono e BeginInvoke é assíncrono.Invoke is synchronous and BeginInvoke is asynchronous. A operação é adicionada à fila de eventos do Dispatcher no especificado DispatcherPriority .The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
Invoke é uma operação síncrona; Portanto, o controle não retornará ao objeto de chamada até que o retorno de chamada seja retornado.Invoke is a synchronous operation; therefore, control will not return to the calling object until after the callback returns.
Aplica-se a
Invoke(Delegate, TimeSpan, Object[])
Executa o delegado especificado no período designado na prioridade especificada com os argumentos especificados de forma síncrona no thread ao qual o Dispatcher está associado.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
Parâmetros
- method
- Delegate
Um delegado para um método que usa os parâmetros especificados em args
, que é enviado por push para a fila de eventos de Dispatcher.A delegate to a method that takes parameters specified in args
, which is pushed onto the Dispatcher event queue.
- timeout
- TimeSpan
A quantidade máxima de tempo de espera para a operação ser iniciada.The maximum amount of time to wait for the operation to start. No entanto, depois que a operação for iniciada, ela será concluída antes que esse método seja retornado.However, once the operation starts, it will complete before this method returns. Para especificar uma espera infinita, use um valor de-1.To specify an infinite wait, use a value of -1. Em uma chamada de mesmo thread, qualquer outro valor negativo é convertido em-1, resultando em uma espera infinita.In a same-thread call, any other negative value is converted to -1, resulting in an infinite wait. Em uma chamada entre threads, qualquer outro valor negativo lança um ArgumentOutOfRangeException .In a cross-thread call, any other negative value throws an ArgumentOutOfRangeException.
- args
- Object[]
Uma matriz de objetos a serem passados como argumentos para o método em questão.An array of objects to pass as arguments to the given method. Pode ser null
se nenhum argumento for necessário.Can be null
if no arguments are needed.
Retornos
O valor retornado do delegado que está sendo invocado ou null
, se o delegado não tiver um valor retornado.The return value from the delegate being invoked or null
if the delegate has no return value.
Exceções
method
é null
.method
is null
.
timeout
é um número negativo diferente de-1 e você está invocando em threads.timeout
is a negative number other than -1, and you're invoking across threads.
Comentários
No WPF, somente o thread que criou um DispatcherObject pode acessar esse objeto.In WPF, only the thread that created a DispatcherObject may access that object. Por exemplo, um thread em segundo plano que é rotacionado do thread da interface do usuário principal não pode atualizar o conteúdo de um Button que foi criado no thread da interface do usuário.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. Para que o thread em segundo plano acesse a propriedade content do Button , o thread em segundo plano deve delegar o trabalho para o Dispatcher associado ao thread da interface do usuário.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. Isso é feito usando o Invoke ou o BeginInvoke .This is accomplished by using either Invoke or BeginInvoke. Invoke é síncrono e BeginInvoke é assíncrono.Invoke is synchronous and BeginInvoke is asynchronous. A operação é adicionada à fila de eventos do Dispatcher no especificado DispatcherPriority .The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
Invoke é uma operação síncrona; Portanto, o controle não retornará ao objeto de chamada até que o retorno de chamada seja retornado.Invoke is a synchronous operation; therefore, control won't return to the calling object until after the callback returns.
Aplica-se a
Invoke(Action, DispatcherPriority, CancellationToken)
Executa a Action especificada de forma síncrona na prioridade especificada no thread ao qual o Dispatcher está associado.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)
Parâmetros
- callback
- Action
Um delegado a ser invocado pelo dispatcher.A delegate to invoke through the dispatcher.
- priority
- DispatcherPriority
A prioridade que determina a ordem na qual o retorno de chamada especificado é invocado em relação às outras operações pendentes no 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
Um objeto que indica se a ação deve ser cancelada.An object that indicates whether to cancel the action.
Aplica-se a
Invoke(DispatcherPriority, Delegate)
Executa o delegado especificado de forma síncrona na prioridade especificada no thread ao qual o Dispatcher está associado.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
Parâmetros
- priority
- DispatcherPriority
A prioridade com a qual o método especificado é invocado em relação às outras operações pendentes na Dispatcher fila de eventos.The priority with which the specified method is invoked, relative to the other pending operations in the Dispatcher event queue.
- method
- Delegate
Um delegado para um método que não usa argumentos, que é enviado por push para a fila de eventos de Dispatcher.A delegate to a method that takes no arguments, which is pushed onto the Dispatcher event queue.
Retornos
O valor retornado do delegado que está sendo invocado ou null
, se o delegado não tiver um valor retornado.The return value from the delegate being invoked or null
if the delegate has no return value.
- Atributos
Exceções
priority
não é uma prioridade válida.priority
is not a valid priority.
method
é null
.method
is null
.
Exemplos
O exemplo a seguir coloca um delegado em uma Dispatcher em Normal usando 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
Comentários
No WPF, somente o thread que criou um DispatcherObject pode acessar esse objeto.In WPF, only the thread that created a DispatcherObject may access that object. Por exemplo, um thread em segundo plano que é rotacionado do thread da interface do usuário principal não pode atualizar o conteúdo de um Button que foi criado no thread da interface do usuário.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. Para que o thread em segundo plano acesse a propriedade content do Button , o thread em segundo plano deve delegar o trabalho para o Dispatcher associado ao thread da interface do usuário.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. Isso é feito usando o Invoke ou o BeginInvoke .This is accomplished by using either Invoke or BeginInvoke. Invoke é síncrono e BeginInvoke é assíncrono.Invoke is synchronous and BeginInvoke is asynchronous. A operação é adicionada à fila de eventos do Dispatcher no especificado DispatcherPriority .The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
Invoke é uma operação síncrona; Portanto, o controle não retornará ao objeto de chamada até que o retorno de chamada seja retornado.Invoke is a synchronous operation; therefore, control will not return to the calling object until after the callback returns.
Aplica-se a
Invoke(Delegate, Object[])
Executa o delegado especificado com os argumentos de forma síncrona no thread ao qual o Dispatcher está associado.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
Parâmetros
- method
- Delegate
Um delegado para um método que usa os parâmetros especificados em args
, que é enviado por push para a fila de eventos de Dispatcher.A delegate to a method that takes parameters specified in args
, which is pushed onto the Dispatcher event queue.
- args
- Object[]
Uma matriz de objetos a serem passados como argumentos para o método em questão.An array of objects to pass as arguments to the given method. Pode ser null
.Can be null
.
Retornos
O valor retornado do delegado que está sendo invocado ou null
, se o delegado não tiver um valor retornado.The return value from the delegate being invoked or null
if the delegate has no return value.
Comentários
No WPF, somente o thread que criou um DispatcherObject pode acessar esse objeto.In WPF, only the thread that created a DispatcherObject may access that object. Por exemplo, um thread em segundo plano que é rotacionado do thread da interface do usuário principal não pode atualizar o conteúdo de um Button que foi criado no thread da interface do usuário.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. Para que o thread em segundo plano acesse a propriedade content do Button , o thread em segundo plano deve delegar o trabalho para o Dispatcher associado ao thread da interface do usuário.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. Isso é feito usando o Invoke ou o BeginInvoke .This is accomplished by using either Invoke or BeginInvoke. Invoke é síncrono e BeginInvoke é assíncrono.Invoke is synchronous and BeginInvoke is asynchronous. A operação é adicionada à fila de eventos do Dispatcher no especificado DispatcherPriority .The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
Invoke é uma operação síncrona; Portanto, o controle não retornará ao objeto de chamada até que o retorno de chamada seja retornado.Invoke is a synchronous operation; therefore, control will not return to the calling object until after the callback returns.
Aplica-se a
Invoke(Action, DispatcherPriority)
Executa a Action especificada de forma síncrona na prioridade especificada no thread ao qual o Dispatcher está associado.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)
Parâmetros
- callback
- Action
Um delegado a ser invocado pelo dispatcher.A delegate to invoke through the dispatcher.
- priority
- DispatcherPriority
A prioridade que determina a ordem na qual o retorno de chamada especificado é invocado em relação às outras operações pendentes no Dispatcher .The priority that determines the order in which the specified callback is invoked relative to the other pending operations in the Dispatcher.
Aplica-se a
Invoke(Action)
Executa o Action especificado de forma síncrona no thread ao qual o Dispatcher está associado.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)
Parâmetros
- callback
- Action
Um delegado a ser invocado pelo dispatcher.A delegate to invoke through the dispatcher.
Aplica-se a
Invoke(Delegate, DispatcherPriority, Object[])
Executa o delegado especificado na prioridade especificada com os argumentos especificados de forma síncrona no thread ao qual o Dispatcher está associado.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
Parâmetros
- method
- Delegate
Um delegado para um método que usa os parâmetros especificados em args
, que é enviado por push para a fila de eventos de Dispatcher.A delegate to a method that takes parameters specified in args
, which is pushed onto the Dispatcher event queue.
- priority
- DispatcherPriority
A prioridade com a qual o método especificado é invocado em relação às outras operações pendentes na Dispatcher fila de eventos.The priority with which the specified method is invoked, relative to the other pending operations in the Dispatcher event queue.
- args
- Object[]
Uma matriz de objetos a serem passados como argumentos para o método em questão.An array of objects to pass as arguments to the given method. Pode ser null
.Can be null
.
Retornos
O valor retornado do delegado que está sendo invocado ou null
, se o delegado não tiver um valor retornado.The return value from the delegate being invoked or null
if the delegate has no return value.
Comentários
No WPF, somente o thread que criou um DispatcherObject pode acessar esse objeto.In WPF, only the thread that created a DispatcherObject may access that object. Por exemplo, um thread em segundo plano que é rotacionado do thread da interface do usuário principal não pode atualizar o conteúdo de um Button que foi criado no thread da interface do usuário.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. Para que o thread em segundo plano acesse a propriedade content do Button , o thread em segundo plano deve delegar o trabalho para o Dispatcher associado ao thread da interface do usuário.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. Isso é feito usando o Invoke ou o BeginInvoke .This is accomplished by using either Invoke or BeginInvoke. Invoke é síncrono e BeginInvoke é assíncrono.Invoke is synchronous and BeginInvoke is asynchronous. A operação é adicionada à fila de eventos do Dispatcher no especificado DispatcherPriority .The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
Invoke é uma operação síncrona; Portanto, o controle não retornará ao objeto de chamada até que o retorno de chamada seja retornado.Invoke is a synchronous operation; therefore, control will not return to the calling object until after the callback returns.
Aplica-se a
Invoke<TResult>(Func<TResult>)
Executa o Func<TResult> especificado de forma síncrona no thread ao qual o Dispatcher está associado.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
Parâmetros de tipo
- TResult
O tipo de valor retornado do delegado especificado.The return value type of the specified delegate.
Parâmetros
- callback
- Func<TResult>
Um delegado a ser invocado pelo dispatcher.A delegate to invoke through the dispatcher.
Retornos
- TResult
O valor retornado por callback
.The value returned by callback
.
Aplica-se a
Invoke<TResult>(Func<TResult>, DispatcherPriority)
Executa a Func<TResult> especificada de forma síncrona na prioridade especificada no thread ao qual o Dispatcher está associado.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
Parâmetros de tipo
- TResult
O tipo de valor retornado do delegado especificado.The return value type of the specified delegate.
Parâmetros
- callback
- Func<TResult>
Um delegado a ser invocado pelo dispatcher.A delegate to invoke through the dispatcher.
- priority
- DispatcherPriority
A prioridade que determina a ordem na qual o retorno de chamada especificado é invocado em relação às outras operações pendentes no Dispatcher .The priority that determines the order in which the specified callback is invoked relative to the other pending operations in the Dispatcher.
Retornos
- TResult
O valor retornado por callback
.The value returned by callback
.
Aplica-se a
Invoke<TResult>(Func<TResult>, DispatcherPriority, CancellationToken)
Executa a Func<TResult> especificada de forma síncrona na prioridade especificada no thread ao qual o Dispatcher está associado.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
Parâmetros de tipo
- TResult
O tipo de valor retornado do delegado especificado.The return value type of the specified delegate.
Parâmetros
- callback
- Func<TResult>
Um delegado a ser invocado pelo dispatcher.A delegate to invoke through the dispatcher.
- priority
- DispatcherPriority
A prioridade que determina a ordem na qual o retorno de chamada especificado é invocado em relação às outras operações pendentes no 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
Um objeto que indica se a operação deve ser cancelada.An object that indicates whether to cancel the operation.
Retornos
- TResult
O valor retornado por callback
.The value returned by callback
.
Aplica-se a
Invoke<TResult>(Func<TResult>, DispatcherPriority, CancellationToken, TimeSpan)
Executa a Func<TResult> especificada de forma síncrona na prioridade especificada no thread ao qual o Dispatcher está associado.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
Parâmetros de tipo
- TResult
O tipo de valor retornado do delegado especificado.The return value type of the specified delegate.
Parâmetros
- callback
- Func<TResult>
Um delegado a ser invocado pelo dispatcher.A delegate to invoke through the dispatcher.
- priority
- DispatcherPriority
A prioridade que determina a ordem na qual o retorno de chamada especificado é invocado em relação às outras operações pendentes no 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
Um objeto que indica se a operação deve ser cancelada.An object that indicates whether to cancel the operation.
- timeout
- TimeSpan
A quantidade máxima de tempo de espera para a operação ser iniciada.The maximum amount of time to wait for the operation to start. Depois que a operação for iniciada, ela será concluída antes que esse método seja retornado.Once the operation has started, it will complete before this method returns. Para especificar uma espera infinita, use um valor de-1.To specify an infinite wait, use a value of -1. Em uma chamada de mesmo thread, qualquer outro valor negativo é convertido em-1, resultando em uma espera infinita.In a same-thread call, any other negative value is converted to -1, resulting in an infinite wait. Em uma chamada entre threads, qualquer outro valor negativo lança um ArgumentOutOfRangeException .In a cross-thread call, any other negative value throws an ArgumentOutOfRangeException.
Retornos
- TResult
O valor retornado por callback
.The value returned by callback
.
Exceções
callback
é null
.callback
is null
.
timeout
é um número negativo diferente de-1 e o método foi invocado entre threads.timeout
is a negative number other than -1, and the method was invoked across threads.
priority
não é uma prioridade válida.priority
is not a valid priority.