Equivalent to InvokeRequired in WPF

前端 未结 4 1322
死守一世寂寞
死守一世寂寞 2021-02-15 23:02

Is there an equivalent to Form.InvokeRequired in WPF, e.g. Dispatcher.InvokeRequired?

4条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-15 23:45

    A possible solution that came to mind is:

    if ( Dispatcher.Thread.Equals( Thread.CurrentThread ) )
    {
        Action( );
    }
    else
    {
        Dispatcher.Invoke( Action );
    }
    

提交回复
热议问题