0
private void ShakeWindow()
    {
        Thread thread = new Thread(new ThreadStart(() =>
            {
                if (this.InvokeRequired)
                {
                    this.Invoke(new Action(/* ref to this instantiated method? */), null);
                }
                else
                {
                    // shake window
                }
            }));
         thread.Start();
    }

我可以通过上面的参考吗?如何?或者有没有更好的解决方案来调用控件?我知道我可以通过以下方式做到这一点:

private void ShakeWindow()
    {
        Thread thread = new Thread(new ThreadStart(ShakeWindowThread));
        thread.Start();
    }
    private void ShakeWindowThread()
    {
        if (this.InvokeRequired)
        {
            this.Invoke(new Action(ShakeWindowThread), null);
        }
        else
        {
            // shake window
        }
    }
4

0 回答 0