Click here to Skip to main content
15,913,300 members
Home / Discussions / C#
   

C#

 
GeneralRe: MultiThread and File process Pin
Ilia Blank18-Jan-10 5:04
Ilia Blank18-Jan-10 5:04 
AnswerRe: MultiThread and File process Pin
wjp_auhtm15-Jan-10 3:54
wjp_auhtm15-Jan-10 3:54 
GeneralRe: MultiThread and File process Pin
AlexB4715-Jan-10 4:06
AlexB4715-Jan-10 4:06 
GeneralRe: MultiThread and File process Pin
wjp_auhtm16-Jan-10 2:29
wjp_auhtm16-Jan-10 2:29 
GeneralRe: MultiThread and File process Pin
Luc Pattyn15-Jan-10 5:13
sitebuilderLuc Pattyn15-Jan-10 5:13 
AnswerRe: MultiThread and File process Pin
Alaric Dailey15-Jan-10 6:00
Alaric Dailey15-Jan-10 6:00 
GeneralRe: MultiThread and File process Pin
AlexB4717-Jan-10 20:45
AlexB4717-Jan-10 20:45 
GeneralRe: MultiThread and File process Pin
Alaric Dailey18-Jan-10 4:37
Alaric Dailey18-Jan-10 4:37 
This is a serialport example, since you keep mentioning COM PORTS I am supposing this is what you are looking for. I will be happy to help out more, but if this still isn't what you need, a better description of what you need in is order.

using System;
using System.IO.Ports;
using System.Threading;
using System.Windows.Forms;

namespace MultiThreadedFileRead
{
    public partial class Form1 : Form
    {
        private readonly object _syncRoot = new object();

        public Form1()
        {
            InitializeComponent();
        }


        private void Form1_Load(object sender, EventArgs e)
        {
            serialPort1.DataReceived += SerialPort1DataReceived;
            serialPort2.DataReceived += SerialPort2DataReceived;
            serialPort3.DataReceived += SerialPort3DataReceived;
        }

        private void SerialPort1DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            ThreadPool.QueueUserWorkItem(ThreadFunc, sender);
        }

        private void SerialPort2DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            ThreadPool.QueueUserWorkItem(ThreadFunc, sender);
        }

        private void SerialPort3DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            ThreadPool.QueueUserWorkItem(ThreadFunc, sender);
        }

        private void ThreadFunc(object state)
        {
            SerialPort port = state as SerialPort;
            if (port != null)
            {
                try
                {
                    //do processing here.
                    
                }
                catch (Exception)
                {
                    //don't let the thread throw directly
                }
            }
        }
    }
}

QuestionSystem.InvalidCastException Query Pin
DwR15-Jan-10 2:45
DwR15-Jan-10 2:45 
AnswerRe: System.InvalidCastException Query Pin
DwR16-Jan-10 2:45
DwR16-Jan-10 2:45 
AnswerRe: System.InvalidCastException Query Pin
Eddy Vluggen17-Jan-10 10:50
professionalEddy Vluggen17-Jan-10 10:50 
GeneralRe: System.InvalidCastException Query Pin
FenixTX10-Feb-10 3:52
FenixTX10-Feb-10 3:52 
GeneralRe: System.InvalidCastException Query Pin
Eddy Vluggen10-Feb-10 4:18
professionalEddy Vluggen10-Feb-10 4:18 
QuestionTrap and Read magnetic tripe card reader [modified] Pin
Kaikus14-Jan-10 23:57
Kaikus14-Jan-10 23:57 
AnswerRe: Trap and Read magnetic tripe card reader Pin
OriginalGriff15-Jan-10 0:24
mveOriginalGriff15-Jan-10 0:24 
AnswerRe: Trap and Read magnetic tripe card reader Pin
Roger Wright15-Jan-10 17:29
professionalRoger Wright15-Jan-10 17:29 
QuestionApplication Domain Pin
dataminers14-Jan-10 23:24
dataminers14-Jan-10 23:24 
AnswerRe: Application Domain Pin
EliottA15-Jan-10 2:44
EliottA15-Jan-10 2:44 
AnswerRe: Application Domain Pin
Eddy Vluggen15-Jan-10 3:11
professionalEddy Vluggen15-Jan-10 3:11 
GeneralRe: Application Domain Pin
dataminers15-Jan-10 9:50
dataminers15-Jan-10 9:50 
GeneralRe: Application Domain Pin
Eddy Vluggen15-Jan-10 11:17
professionalEddy Vluggen15-Jan-10 11:17 
GeneralRe: Application Domain Pin
dataminers16-Jan-10 2:23
dataminers16-Jan-10 2:23 
GeneralRe: Application Domain Pin
Eddy Vluggen16-Jan-10 8:50
professionalEddy Vluggen16-Jan-10 8:50 
GeneralRe: Application Domain Pin
dataminers15-Jan-10 10:31
dataminers15-Jan-10 10:31 
QuestionCaching powers of 2 -- performance consideration Pin
Lutosław14-Jan-10 22:36
Lutosław14-Jan-10 22:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.