Exemplo n.º 1
0
        /// <summary>
        /// When the method "closing" is called,
        /// the following code is run.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnClose_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (m_PosCommon != null)
                {
                    //Cancel the device
                    m_PosCommon.DeviceEnabled = false;

                    //Release the device exclusive control right.
                    m_PosCommon.Release();

                    //Finish using the device.
                    m_PosCommon.Close();
                }
            }
            catch (PosControlException)
            {
            }
        }
Exemplo n.º 2
0
 private static void CloseDevice(PosCommon device)
 {
     if (device == null)
     {
         return;
     }
     try
     {
         if (device.Claimed)
         {
             device.Release();
         }
     }
     catch
     {
     }
     try
     {
         device.Close();
     }
     catch
     {
     }
 }