The event does not shoot raspberries pi mono

I am following this post to develop a client for request notification. http://www.youdidwhatwithtsql.com/started-query-notifications-sql-server-2008-r2/1676/ I tried this code both on Visual Studio and on mono on my PC, and they seem to work on onDependencyChange event. However, when I transfer it to a raspberry pi with a mono kit installed, it does not seem to work. I cannot debug since pi is in a different place and I use SSH to remotely access it.

static void Main(string[] args)
    {
        Console.WriteLine ("-----------------APPLICATION STARTED------------------");
        var connection = new SqlConnection(connectionString);
        SqlDependency.Start(connectionString);
        RefreshDataWithSqlDependency();

        Console.WriteLine ("Why is it here?");
        //blocks thread so you can read message
        Console.ReadLine();
        SqlDependency.Stop(connectionString);
    }

    static void RefreshDataWithSqlDependency()
    {
        //remove existing dependency if necessary
        if (dependency != null)
        {
            dependency.OnChange -= onDependencyChange;
            dependency = null;
        }

        using (SqlConnection connection = new SqlConnection(connectionString))
        {
            connection.Open();

            SqlCommand command = new SqlCommand("SELECT ipAddress FROM dbo.dbDevices", connection);

            //Create a dependency and associate it with command
            dependency = new SqlDependency(command, null, 1);

            //Subscribe to the SqlDependency event.
            dependency.OnChange += new OnChangeEventHandler(onDependencyChange);

            //Start dependency listener
            SqlDependency.Start(connectionString);

            //execute command and refresh data
            RefreshData(command);
        }
    }

    private static void onDependencyChange(Object o, SqlNotificationEventArgs args)
    {
        Console.WriteLine("ondep gets hit");
        if ((args.Source.ToString() == "Data") || (args.Source.ToString() == "Timeout"))
        {
            Console.WriteLine("Refreshing data due to {0}", args.Source);
            RefreshDataWithSqlDependency();

        }
        else
        {
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Data not refreshed due to unexpected SqlNotificationEventArgs: Source={0}, Info={1}, Type={2}", args.Source, args.Info, args.Type.ToString());
            Console.ForegroundColor = ConsoleColor.Gray;
        }
    }

    private static void RefreshData(SqlCommand command)
    {
        using (var reader = command.ExecuteReader())
        {
            Console.Clear();
            while (reader.Read())
            {
                Console.WriteLine("ip = {0}", reader[0]);
            }
        }
    }

.WriteLine RefreshDataWithSqlDependency, Run > Run With > Microsoft.NET Mono 4.0.2, , , RefreshDataWithSqlDependency, , , . .

0
1

SSH.

Ras-pi :

mono \
 --debug \
 --debugger-agent=transport=dt_socket,address=0.0.0.0:10000,suspend=y,server=y,keepalive=250 \
foodata.exe

(, 0.0.0.0)

, Xamarian Studio/MonoDevelop IDE cmd.

Linux:

export MONODEVELOP_SDB_TEST=1 
monodevelop

OS-X ( Xam Studio cmd MonoDevelop, , :

export MONODEVELOP_SDB_TEST=1 
/Applications/Xamarin\ Studio.app/Contents/MacOS/XamarinStudio

Windows ( ):

set MONODEVELOP_SDB_TEST=1 
<path>\XamarinStudio.exe

IDE /, , :

Run / Run With / Custom Command Soft Mono Debugger 

. , env var cmd.

Launch Soft Debugger:

Command : ssh YourRaspiLogin@RasPiPassword -L 10000:127.0.0.1:10000 
Arguments : <leave empty>
IP : YourRasPiHostNameOrIPAddress
Port: : 10000

"".

ssh, ( ), .. . - ssh; .. "ssh" .

, , IDE , ;-)

0

Source: https://habr.com/ru/post/1599444/


All Articles