嘿伙计们,当我的应用程序关闭时,我得到了这个异常。CustomerReadySub 是我订阅的事件。
错误发生在这一行
fTypeLabel.Invoke(new MethodInvoker(fuelTypeChosen));
public void CustomerReadySub(object sender, CustomerReadyEventArgs fuel)
{
// code to handle the event
string CustReady = null;
//checks what fuel is chosen and then activates the pump
fuelType = fuel.SelectedFuel.ToString();
if (!String.IsNullOrEmpty(fuelType))
{
fTypeLabel.Invoke(new MethodInvoker(fuelTypeChosen));
if (fuelType == "Unleaded") //checks fuel type and displays price accordingly
{
pplText.Invoke(new MethodInvoker(petrol));
}
else
{
pplText.Invoke(new MethodInvoker(diesel));
}
CustReady = "READY";
WCFPump.sendReady(CustReady);
}
while (WCFPump.getOK() == 0) { /*do nothing*/} //used to loop around until OK is retrieved
if (pumpID == WCFPump.getOK())
{
CustGen.ActivatePump();
}
}
private void fuelTypeChosen()
{
fTypeLabel.Text = fuelType;
}
我不确定是什么导致了问题。