- Messages
- 9
- Country

I got a problem with the key event failures. Below the relevant piece of the c# code.
By clicking the button the electrical failure occurs and everything is well, but if I click it again I get exception 9 and exception 29 (Duplicate ID and Duplicate Event ID).
I think I have mistunderstood something here. Maybe somebody could have a look and give me some advice how to solve it...
By clicking the button the electrical failure occurs and everything is well, but if I click it again I get exception 9 and exception 29 (Duplicate ID and Duplicate Event ID).
I think I have mistunderstood something here. Maybe somebody could have a look and give me some advice how to solve it...
Code:
// Enums
enum FAILURES
{
KEY_TOGGLE_ELECTRICAL_FAILURE,
KEY_TOGGLE_VACUUM_FAILURE
}
enum NOTIFICATION_GROUPS
{
GROUP_0
}
// Eventhandler
void simconn_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT data)
{
switch (data.uEventID)
{
case (uint)FAILURES.KEY_TOGGLE_ELECTRICAL_FAILURE:
MessageBox.Show("ELECTRICAL");
break;
case (uint)FAILURES.KEY_TOGGLE_VACUUM_FAILURE:
MessageBox.Show("VACUUM");
break;
}
}
// Raise event
private void TriggerFailureEvent(FAILURES failureEvent)
{
string eventName = null;
switch (failureEvent)
{
case FAILURES.KEY_TOGGLE_ELECTRICAL_FAILURE:
eventName = "TOGGLE_ELECTRICAL_FAILURE";
break;
case FAILURES.KEY_TOGGLE_VACUUM_FAILURE:
eventName = "TOGGLE_VACUUM_FAILURE";
break;
}
simconn.MapClientEventToSimEvent(failureEvent, eventName);
simconn.AddClientEventToNotificationGroup(NOTIFICATION_GROUPS.GROUP_0, failureEvent, true);
simconn.SetNotificationGroupPriority(NOTIFICATION_GROUPS.GROUP_0, SimConnect.SIMCONNECT_GROUP_PRIORITY_HIGHEST);
simconn.TransmitClientEvent(SimConnect.SIMCONNECT_OBJECT_ID_USER, failureEvent, 0, NOTIFICATION_GROUPS.GROUP_0, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY);
}
// Button click
private void TestFailure_Click(object sender, EventArgs e)
{
// DEBUGGING FUNCTION
TriggerFailureEvent(FAILURES.KEY_TOGGLE_ELECTRICAL_FAILURE);
}
