Beispiel #1
0
        /// <summary>
        ///  Executes when WriteToComPortDelegate1 completes.
        /// </summary>
        /// <param name="ar"> the value returned by the delegate's BeginInvoke method </param>

        internal void WriteCompleted(IAsyncResult ar)
        {
            WriteToComPortDelegate deleg = null;
            string msg     = null;
            bool   success = false;

            //  Extract the value returned by BeginInvoke (optional).

            msg = System.Convert.ToString(ar.AsyncState);

            //  Get the value returned by the delegate.

            deleg = (( WriteToComPortDelegate )((( AsyncResult )(ar)).AsyncDelegate));

            success = deleg.EndInvoke(ar);

            if (success)
            {
                if (null != UserInterfaceData)
                {
                    UserInterfaceData("UpdateStatusLabel", "", Color.Black);
                }
            }

            //  Add any actions that need to be performed after a write to the COM port completes.
            //  This example displays the value passed to the BeginInvoke method
            //  and the value returned by EndInvoke.

            Console.WriteLine("Write operation began: " + msg);
            Console.WriteLine("Write operation succeeded: " + success);
        }
Beispiel #2
0
        /// <summary>
        /// Method that is called after write to COM port is finished.
        /// </summary>
        /// <param name="ar"></param>
        public void WriteCompleted(IAsyncResult ar)
        {
            WriteToComPortDelegate deleg = null;
            string msg     = null;
            bool   success = false;

            //Extract the value returned by BeginInvoke (optional)
            msg = ar.AsyncState.ToString();

            //Get the value returned by the delegate.
            deleg = ((WriteToComPortDelegate)(((AsyncResult)(ar)).AsyncDelegate));

            msg = ar.AsyncState.ToString();

            success = deleg.EndInvoke(ar);

            if (UserInterfaceData != null)
            {
                if (success)
                {
                    UserInterfaceData(ComPortEvent.ReportSerialSuccess, msg);
                }
                else
                {
                    UserInterfaceData(ComPortEvent.ReportSerialError, "Write operation started  " + msg + " did not return success");
                }
            }
        }
Beispiel #3
0
        private void _WriteToGateCompleted(IAsyncResult iar)
        {
            string message;
            bool   success;

            message             = iar.AsyncState as string;
            success             = writeToGateDelegate.EndInvoke(iar);
            statusTransfer.Text = "Pengiriman Pesan [" + message + "] sukses.";
        }
Beispiel #4
0
        private void _WriteToInputSerialCompleted(IAsyncResult iar)
        {
            string message;

            Boolean success;

            message             = iar.AsyncState as string;
            success             = writeToInputDelegate.EndInvoke(iar);
            statusTransfer.Text = "Pengiriman pesan [ " + message + " ] sukses.";
        }