Ejemplo n.º 1
0
    public static void Main(string[] args)
    {
        if ((args.Length < 1) || (args.Length > 2))
        {
            Console.WriteLine("Usage: SimpleSubscriber <eventexpr> [<filter>]");
            Environment.Exit(1);
        }

        string eventexpr = args[0];
        string filter    = (args.Length < 2) ? null : args[1];

        ATMI.tpinit(null);
        try
        {
            ATMI.tpsetunsol(new UnsolHandler(tpunsol));
            try
            {
                Console.WriteLine("Subscribing to events matching '" + eventexpr + "'");
                int handle = ATMI.tpsubscribe(eventexpr, filter, null, 0);
                try
                {
                    ProcessMessages(5);
                }
                finally
                {
                    ATMI.tpunsubscribe(handle, 0);
                }
            }
            finally
            {
                ATMI.tpsetunsol(null);
            }
        }
        finally
        {
            ATMI.tpterm();
        }
    }