When inside the switch statement below, both messages are triggered successfully, but the dispatch function only sends (passes on) the first case which is triggered, and the message is sent this one time, but when the next case is triggered... nothing. When the second case MSG_PART_INITIALIZE is triggered shortly after the first message, the dispatch function doesn't do anything... iow ~ the dispatch only works the first time out when case MSG_PART_UPDATE is triggered.
Using the below code sample, let's say you have an event handler that sends object messages to the function PartUpdate as shown below. The message is then type-cast to a Message class object to then set some variables from there.
QUESTION: when the switch receives the partSig variable, both case MSG_PART_UPDATE as well as MSG_PART_INITIALIZE should fall thru and either case should call otherClass.dispatch(partSi
g). Again, when the first case MSG_PART_UPDATE is triggered, dispatch is called successfully, but then when another message is sent which triggers shortly thereafter which triggers MSG_PART_INITIALIZE... dispatch does not send the messsage on to otherClass.dispatch(partSi
g);
Can anyone help me resolve this? Why does the dispatch only pass the message on to otherClass only once? but not for the next message that is triggered?
- - - - - - - - - - - - - - - - -
public OtherClass otherClass
// upon logon to the app a new OtherClass object is instantiated elsewhere...
otherClass = new OtherClass();
// const int types declared in another class..
public const int MSG_PART_UPDATE = 4001;
public const int MSG_PART_INITIALIZE= 4002;
public void PartUpdate(object theMsg)
{
Message msg = (Message) theMsg;
string part= msg.Part;
int partSig = msg.MsgId;
switch (partSig)
{
case MSG_PART_UPDATE:
case MSG_PART_INITIALIZE:
{
OtherClass otherClass = AnotherClass.Instance.othe
rClass;
if (otherClass != null)
otherClass.dispatch(theMsg
);
break;
}
default:
Console.Out.WriteLine("got
msg, signature = " + partSig);
}
}