C#条带状态文本更新问题

C#条带状态文本更新问题,c#,C#,我在这里是因为按钮点击事件中的一个奇怪行为。代码见附件 问题是第一条StripStatus消息从未显示。你知道为什么吗 private void FireBtn_Click(object sender, EventArgs e) { // Control local controls for launching attack AwayTableLayoutPanel.Enabled = false; AwayCancelBtn.En

我在这里是因为按钮点击事件中的一个奇怪行为。代码见附件

问题是第一条StripStatus消息从未显示。你知道为什么吗

    private void FireBtn_Click(object sender, EventArgs e)
    {
        // Control local controls for launching attack
        AwayTableLayoutPanel.Enabled = false;
        AwayCancelBtn.Enabled = false;
        FireBtn.Enabled = false;


        ////////////// Below statusBar message is never displayed but the folowing sound clip is.
        GameToolStripStatusLabel.Text = "(Home vs. Away)(Attack Coordinate: (" +
            GameModel.alphaCoords(GridLock.Column) + "," + GridLock.Row + "))(Action: Fire)";
        ////////////////////////////////////////////

        if (audio)
        {
            SoundPlayer fire = new SoundPlayer(Properties.Resources.fire);
            fire.PlaySync();
            fire.Dispose();
        }


        // compile attack message
        XmlSerializer s;
        StringWriter w;

        FireGridUnit fireGridUnit = new FireGridUnit();
        fireGridUnit.FireGridLocation = GridLock;

        s = new XmlSerializer(typeof(FireGridUnit));
        w = new StringWriter();
        s.Serialize(w, fireGridUnit);


        //////////////////////////////////////////////////////////
        // send attack message
        GameMessage GameMessageAction = new GameMessage();
        GameMessageAction.gameAction = GameMessage.GameAction.FireAttack;
        GameMessageAction.statusMessage = w.ToString();

        s = new XmlSerializer(typeof(GameMessage));
        w = new StringWriter();
        s.Serialize(w, GameMessageAction);
        SendGameMsg(w.ToString());

        GameToolStripStatusLabel.Text = "(Home vs. Away)(Attack Coordinate: (" +
            GameModel.alphaCoords(GridLock.Column) + "," + GridLock.Row + "))(Action: Awaiting Fire Result)";

    }
编辑:如果我在StripStatus消息后放入messageBox,状态将更新。

在分配文本属性后,会发生很多事情。在Click事件处理程序执行完毕之前,标签不会以可视方式更新。直到UI线程再次空闲,它的绘制事件才能运行

可以通过调用条带的Update()方法强制它立即绘制:


@克里斯:声音样本播放了将近2秒钟,所以状态应该先更新,而且时间还很充裕。嘿,nobugz!一如既往的优秀!:)
GameToolStripStatusLabel.Text = "...";
GameToolStrip.Update();