0

Form1 クラスに含まれるメソッドがあります

 public void ExecuteMessageOperations(MSMQMessage MSMQ)
    {
        switch (MSMQ.MesType)
        {
            case "01": { label1.Text = MSMQ.MesContent; MessageBox.Show(MSMQ.MesContent); button1.Text = MSMQ.MesContent; };
                break;
            case "02":
                {
                    dataGridView1.Columns.Add("Data", "Data");
                    dataGridView1.Rows.Add(MSMQ.MesContent);

                };
                break;
            case "03":
                {
                    string[] separated = MSMQ.MesContent.Split(new Char[] { ',' });
                    try
                    {
                        Rectangle rect = new Rectangle(Convert.ToInt16(separated[0]),
                            Convert.ToInt16(separated[1]), Convert.ToInt16(separated[2]),
                            Convert.ToInt16(separated[2]));
                        SolidBrush brush = new SolidBrush(XMLConfigs.GetBrushColor());
                        Graphics Grph = pictureBox1.CreateGraphics();
                        Grph.FillEllipse(brush, rect);

                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Wrong parameters");
                    };
                };
                break;
        }

そして、MSMQMessageThread を呼び出して Form1 の外に格納するクラス。このクラスにはメソッドがあります

public void PerformOperations()
    {
        while (true)
        {
            try
            {
                Form1 f = new Form1();
                f.ExecuteMessageOperations(MSMQMessage.ReceiveMessage(@".\private$\TestQueue"));
            }
            catch (System.Messaging.MessageQueueException) { }
        }
    }

コードは正常にコンパイルされますが、メソッド ExecuteMessageOperations は何もしません。間違いはどこにあり、メソッド ExecuteMessageOperations で Form1 コンポーネントにアクセスするにはどうすればよいですか? PS私の英語でごめんなさい

4

1 に答える 1

0

switch ステートメントと「ステップ オーバー」の場所にブレークポイントを配置します。そもそも実際にメソッドを呼び出しているかどうかをお知らせください。

于 2013-04-04T15:11:09.857 に答える