如果控制器应用程序已经运行,如何将参数传递给它?
我在Windows Mobile中使用控制台应用程序来处理传入的消息拦截。在同一控制台应用程序中,我接受基于参数的参数(字符串args []),注册消息拦截器。
InterceptorType是一个枚举
static void Main(string[] args)
{
if (args[0] == "Location")
{
addInterception(InterceptorType.Location, args[1],args[2]);
}
}
private static void addInterception(InterceptorType type, string Location, string Number )
{
if (type == InterceptorType.Location)
{
using (MessageInterceptor interceptor = new MessageInterceptor(InterceptionAction.NotifyAndDelete, false))
{
interceptor.MessageCondition = new MessageCondition(MessageProperty.Sender, MessagePropertyComparisonType.Contains, Number, false);
string myAppPath = Assembly.GetExecutingAssembly().GetName().CodeBase;
interceptor.EnableApplicationLauncher("Location", myAppPath);
interceptor.MessageReceived += new MessageInterceptorEventHandler(interceptor_MessageReceived);
}
}
}
static void interceptor_MessageReceived(object sender, MessageInterceptorEventArgs e)
{
//Do something
}
我把它作为一个控制台应用程序,因为我希望它继续在后台运行并拦截传入的消息。
这是第一次正常工作。但问题是我必须继续调用addInterception方法来添加后续的拦截规则。这使得控制台应用程序每次添加规则时都会反复启动。我如何只运行一次并添加更多的消息拦截器规则?
没有找到相关结果
已邀请:
2 个回复
到街客核
儿童过程:
请注意,codeplex具有托管服务库。
闪脖