G
Guest
Hi, I have a problem where I use an event to signal another part of my
program to process a message. The idea is something like this
Class1 handles the first part of the processing for a message received from
the network. When I reach a certain point in the processing an event is
raised and Class2 is supposed to continue processing the message. The message
is passed as an argument through the delegate and it works apart from one
thing; timing.
Sometimes Class2 doesn't its processing untl 100 ms after the event is raised.
In Class1 I have the following code:
public event MyEventHandler Notify;
public delegate void MyEventHandler(MyMessageClass message, Class1 sender);
public void ProcessMessage(MyMessageClass messageObject)
{
//Do the first part of processing on messageObject
// Notify Class2 to take over
Notify(messageObject, this);
}
In Class2 I have the following code:
private void ProcessMessage_Notify(MyMessageClass message, Class1 sender)
I also subscribe to the event using the code
Class1.Notify += new MyEventHandler(ProcessMessage_Notify);
Why is there a delay when signaling like this?
Is there a better way to get the same functionaliy to avoid this delay?
I need to separate the processing in different classes since they not belong
to the same dll in my project and I need to keep them separated.
Thank you,
Henrik
program to process a message. The idea is something like this
Class1 handles the first part of the processing for a message received from
the network. When I reach a certain point in the processing an event is
raised and Class2 is supposed to continue processing the message. The message
is passed as an argument through the delegate and it works apart from one
thing; timing.
Sometimes Class2 doesn't its processing untl 100 ms after the event is raised.
In Class1 I have the following code:
public event MyEventHandler Notify;
public delegate void MyEventHandler(MyMessageClass message, Class1 sender);
public void ProcessMessage(MyMessageClass messageObject)
{
//Do the first part of processing on messageObject
// Notify Class2 to take over
Notify(messageObject, this);
}
In Class2 I have the following code:
private void ProcessMessage_Notify(MyMessageClass message, Class1 sender)
I also subscribe to the event using the code
Class1.Notify += new MyEventHandler(ProcessMessage_Notify);
Why is there a delay when signaling like this?
Is there a better way to get the same functionaliy to avoid this delay?
I need to separate the processing in different classes since they not belong
to the same dll in my project and I need to keep them separated.
Thank you,
Henrik