1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Using serialport and backgroundworker

Discussion in 'C#' started by memorex, Sep 10, 2010.

  1. memorex

    memorex New Member

    Sep 10, 2010
    Likes Received:
    Trophy Points:
    I need to make a project that takes data from a uC through serial port and insert it in some databases. I want to take the data from 5 sensors, i'm sending the data from al 5 sensors once per hour. The problem is that I want to use backgroundworker for taking the data from serial port, and insert in the database and another backgroundworker for the graphic interface of the program(the graphic interface contain a DataGridView that loads from the database last 200 entries and 5 richtextboxes for instant values of the sensors).
    Now I have this code:

    In constructor:
    ComPort.DataReceived += new SerialDataReceivedEventHandler(port_PrimireDate);
    Method, for datareceived event:
    private void port_PrimireDate(object sender, SerialDataReceivedEventArgs e)
    string data;
    data = ComPort.ReadExisting();

    For now I want to make backgroundworker for taking data from port, I tried some versions but I have a lot of errors. If someone can give me an idea it will be great.

Share This Page