I use the MessageInterceptor with several rules to handle incoming messages.
My problem is that according to this page (see the code below), he mentions that a key part of the logic is to load the MessageInterceptor object in the Form Load and check whether IsApplicationLauncherEnabled
and bind it again to the MessageReceived event.
This is actually required when the application is not running and needs to be started when a message is received.
So does this mean that if I have about 10 message rules, i should create 10 MessageInterceptor objects at Form_Load
to actually handle the messages?
private void Form1_Load(object sender, EventArgs e)
{
if (MessageInterceptor.IsApplicationLauncherEnabled("testapp"))
{
mi = new MessageInterceptor("testapp");
}
else
{
mi = new MessageInterceptor(InterceptionAction.NotifyAndDelete);
mi.MessageCondition = new MessageCondition(MessageProperty.Body,
MessagePropertyComparisonType.StartsWith, "test:", false);
mi.EnableApplicationLauncher("testapp", "\\Program Files\\DeviceApplication1\\DeviceApplication1.exe");
}
mi.MessageReceived += new MessageInterceptorEventHandler(mi_MessageReceived);
}