我有包含在 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对不起我的英语