我有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组件? 附:对不起我的英文
答案 0 :(得分:0)
在switch语句和'step over'之间放置一个断点。如果它实际上是在调用该方法,请告诉我们。