namespace TOC
{
delegate void message_fPtoEMS(Message msg);
delegate void message_fEMStoMax(Message msg);
delegate void message_fMaxtoEMS(Message msg);
delegate void message_fEMStoP(Message msg);
public partial class Form1 : Form
{
public void Controller()
{
Patient agentP = new Patient("agentP");
EMS agentEMS = new EMS("agentEMS");
Max agentAI = new Max("agentAI");
agentP.fPatienttoEMS = new
message_fPtoEMS(agentEMS.Receive_from_Patient);
agentEMS.fEMStoAI = new message_fEMStoMax(agentAI.Receive_from_EMS);
agentAI.fAItoEMS = new message_fMaxtoEMS(agentEMS.Receive_from_AI);
agentEMS.fEMStoP = new message_fEMStoP(agentP.Receive_from_EMS);
Thread T_agentP = new Thread(agentP.Run);
T_agentP.Start();
Thread T_agentEMS = new Thread(agentEMS.Run);
T_agentEMS.Start();
Thread T_agentAI = new Thread(agentAI.Run);
T_agentAI.Start();
}
public AI_sim()
{
InitializeComponent();
Thread control = new Thread(() => Controller());
control.Start();
}
private void AI_sim_Load(object sender, EventArgs e)
{
}
}
class Patient
{
public string agentname;
public Patient(string name) { agentname = name; }
public void Run()
{
assignvalue();
}
public void assignvalue()
{
int age
age = random.Next(0, 100);
form1.textbox1.text = convert.tostring(age);
} // Assign Value method end...
我尝试过在堆栈溢出时发布的委托解决方案,但是没有用。我已经花了一个多星期的时间进行搜索。有人可以告诉我如何从Patient类更新表格。是否有任何好的方法可以在UI表单中进行更改或控制。