Exemplo n.º 1
0
        private async void _pressMeButton_Click
        (
            object sender,
            EventArgs e
        )
        {
            try
            {
                using (IrbisConnection connection
                           = new IrbisConnection())
                {
                    _pressMeButton.Enabled = false;
                    _press2Button.Enabled  = false;
                    try
                    {
                        //AsyncClientSocket socket
                        //    = new AsyncClientSocket(connection);
                        //connection.SetSocket(socket);

                        //AsyncSocketAdapter adapter
                        //    = new AsyncSocketAdapter
                        //        (
                        //            connection,
                        //            connection.Socket
                        //        );
                        //connection.SetSocket(adapter);

                        connection.ParseConnectionString
                        (
                            _connectionString
                        );

                        await connection.ConnectAsync();

                        _output.WriteLine("Connected");

                        int maxMfn
                            = await connection.GetMaxMfnAsync();

                        _output.WriteLine
                        (
                            "Max MFN={0}",
                            maxMfn
                        );

                        await connection.DisconnectAsync();
                    }
                    finally
                    {
                        _pressMeButton.Enabled = true;
                        _press2Button.Enabled  = true;
                    }
                }

                _output.WriteLine("Diconnected");
                _output.WriteLine(string.Empty);
            }
            catch (Exception exception)
            {
                _output.WriteLine
                (
                    exception.ToString()
                );

                Clipboard.SetText(exception.ToString());
            }
        }