Click here to Skip to main content
15,946,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,
C++
I am trying to get data from POS machine to my pc .My program is magnetic card reading program using my POS machine. 1st time I swipe the card then data received successfully and again I just swipe the card data was receiving slowly.As I think some thread is running.here is code and errors.  


What I have tried:

C#
namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        SerialPortManager _spManager;
        public Form1()
        {
            InitializeComponent();
            UserInitialization();
           _spManager.StartListening();

            label1.Hide();
            label12.Hide();
            comboBox1.Hide();



        }
      
        private void UserInitialization()
        {
            _spManager = new SerialPortManager();
            SerialSettings mySerialSettings = _spManager.CurrentSerialSettings;
            bindingSource1.DataSource = mySerialSettings;
            portNameComboBox.DataSource = mySerialSettings.PortNameCollection;
            baudRateComboBox.DataSource = mySerialSettings.BaudRateCollection;
             dataBitsComboBox.DataSource = mySerialSettings.DataBitsCollection;
             parityComboBox.DataSource = Enum.GetValues(typeof(System.IO.Ports.Parity));
             stopBitsComboBox.DataSource = Enum.GetValues(typeof(System.IO.Ports.StopBits));


            _spManager.NewSerialDataRecieved += new EventHandler<SerialDataEventArgs>(_spManager_NewSerialDataRecieved);
            this.FormClosing += new FormClosingEventHandler(MainForm_FormClosing);
        }


        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            _spManager.Dispose();
        }

        void _spManager_NewSerialDataRecieved(object sender, SerialDataEventArgs e)
        {

            if (this.InvokeRequired)
            {
                // Using this.Invoke causes deadlock when closing serial port, and BeginInvoke is good practice anyway.
                this.BeginInvoke(new EventHandler<SerialDataEventArgs>(_spManager_NewSerialDataRecieved), new object[] { sender, e });
                return;
            }

            int maxTextLength = 1000; // maximum text length in text box
            if (tbData.TextLength > maxTextLength)
            {
                tbData.Text = tbData.Text.Remove(0, tbData.TextLength - maxTextLength);
            }
            // This application is connected to a GPS sending ASCCI characters, so data is converted to text
    
             
             string str = Encoding.ASCII.GetString(e.Data);
            Console.WriteLine(str);
         
                tbData.AppendText(str);
          
            tbData.ScrollToCaret();
         



           
        }
8098765432000007
'AES Card Encoder.vshost.exe' (CLR v4.0.30319: AES Card Encoder.vshost.exe): Loaded 'C:\WINDOWS\assembly\GAC\Microsoft.Office.Interop.Excel\12.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Excel.dll'. Module was built without symbols.
'AES Card Encoder.vshost.exe' (CLR v4.0.30319: AES Card Encoder.vshost.exe): Loaded 'C:\WINDOWS\assembly\GAC\office\12.0.0.0__71e9bce111e9429c\office.dll'. Module was built without symbols.
'AES Card Encoder.vshost.exe' (CLR v4.0.30319: AES Card Encoder.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Dynamic\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Dynamic.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'AES Card Encoder.vshost.exe' (CLR v4.0.30319: AES Card Encoder.vshost.exe): Loaded 'Anonymously Hosted DynamicMethods Assembly'. 

8098
765432000007

80987
654320
000
7
The thread 0xe44 has exited with code 259 (0x103).
The thread 0x2890 has exited with code 259 (0x103).
What is this "The thread 0xe44 has exited with code 259 (0x103)." error?
Posted
Updated 22-Dec-16 20:52pm

It is not an error, actually. Some info here: c# - What is a thread exit code - Stack Overflow[^].
 
Share this answer
 
Comments
Dushan Madushanka 23-Dec-16 2:42am    
Why data coming slowly than 1st time?
Dushan Madushanka 23-Dec-16 2:47am    
Why data receiving slower than 1st time?
C#
Why data receiving slower than 1st time?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900