Multiple Tables

Apr 29, 2016 at 1:25 AM
Edited Apr 29, 2016 at 1:27 AM
Hi,

Is it possible to monitor multiple tables? Something like the code below? Where do I put the Stop method? Thanks.

static void Main(string[] args) {
        using (var depSecurityILSKey = new SqlTableDependency<Model1>(ConfigurationManager.ConnectionStrings["default"].ConnectionString, "Table1", mapperTbl1))
            {
                depTbl1.OnChanged += depTbl1Changed;
                depTbl1.Start();

                Console.WriteLine("Press a key to exit");
                Console.ReadKey();

                depTbl1.Stop();
            }


        using (var dep = new SqlTableDependency<MFilesLoginAccount>(ConfigurationManager.ConnectionStrings["default"].ConnectionString, "Table2", mapperTbl2))
            {
                depTbl2.OnChanged += Changed;
                depTbl2.Start();

                Console.WriteLine("Press a key to exit");
                Console.ReadKey();

                depTbl2.Stop();
            }
}
Apr 29, 2016 at 7:59 AM
Yes it is possible
But the code you show me is not correct, because the thread is stopped on the first "Console.ReadKey();"

Please, look at this example:
https://tabledependency.codeplex.com/wikipage?title=WPF

The application defines a global variable and register an event handler without stopping.

If you have problem, feel free to contact me again.
Apr 29, 2016 at 4:49 PM
Thanks! Issues resolved.