Click here to Skip to main content
15,879,535 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to record the video from a System.Windows.Forms.Panel? Pin
Pete O'Hanlon13-Mar-13 2:08
mvePete O'Hanlon13-Mar-13 2:08 
AnswerRe: How to record the video from a System.Windows.Forms.Panel? Pin
Dave Kreskowiak13-Mar-13 6:47
mveDave Kreskowiak13-Mar-13 6:47 
QuestionHelp! Create File Pin
makhondi13-Mar-13 0:59
makhondi13-Mar-13 0:59 
AnswerRe: Help! Create File Pin
Garth J Lancaster13-Mar-13 1:12
professionalGarth J Lancaster13-Mar-13 1:12 
AnswerRe: Help! Create File Pin
Pete O'Hanlon13-Mar-13 1:13
mvePete O'Hanlon13-Mar-13 1:13 
AnswerRe: Help! Create File Pin
Garth J Lancaster13-Mar-13 1:13
professionalGarth J Lancaster13-Mar-13 1:13 
GeneralRe: Help! Create File Pin
GuyThiebaut13-Mar-13 1:48
professionalGuyThiebaut13-Mar-13 1:48 
QuestionMultiple Serial Ports over TCPIP Pin
ritmas12-Mar-13 23:27
ritmas12-Mar-13 23:27 
Hello, I'm doing a project to send information from multiple serial ports over TCPIP network.

The approach I am using is as follows:
    Use BackgroundWorker for each serial port that is used to capture the information received.
    I use a common method to treat the information received and stored in a queue using locks.


C#
//private String _datos;
       Queue _cola = new Queue();


private void bw_DoWork(object sender, DoWorkEventArgs e)
{

    BackgroundWorker bw = sender as BackgroundWorker;
    string port = (string)e.Argument;

    //put all your serial port code here
    SerialPort sprt = new SerialPort(port);
    sprt.BaudRate = 4800;
    sprt.Parity = Parity.None;
    sprt.StopBits = StopBits.One;
    sprt.DataBits = 8;
    sprt.Handshake = Handshake.None;
    try
    {
        sprt.Open();
    }
    catch (Exception)
    {
        MessageBox.Show("Check port");
        return;
    }

    while (!bw.CancellationPending)
    {
        string indata = sprt.ReadLine();

        lock (_cola)
        {
            _cola.Enqueue(indata);

        }
        //update the graph
        BeginInvoke((Action)(() = UpdateGraph(port)));
    }
    //user wants to stop the worker
    sprt.Close();

}


private void UpdateGraph(string port)
{
    //messures is shared by several threads: you must lock it to access it safely
    lock (_cola)
    {

        string text = Leer();

        rtbOutput.AppendText(text );
        rtbOutput.ScrollToCaret();

    }
    //the curve has been updated so refresh the graph
}


I found that if I open several ports and FIFO is slower getting data extracting data, the program is "locked." So far all I do is get the information even RichTextBox, but the purpose is to send this data via socket to another computer.
I understand that I should make a thread to avoid these locks but how should do so within the BackgroundWorker?

modified 13-Mar-13 5:44am.

QuestionRegarding K-means Text Clustering Pin
sunny funny12-Mar-13 21:44
sunny funny12-Mar-13 21:44 
AnswerRe: Regarding K-means Text Clustering Pin
Pete O'Hanlon12-Mar-13 21:51
mvePete O'Hanlon12-Mar-13 21:51 
QuestionTask ContinueWith Pin
MAW3012-Mar-13 16:20
MAW3012-Mar-13 16:20 
AnswerRe: Task ContinueWith Pin
Simon_Whale13-Mar-13 0:11
Simon_Whale13-Mar-13 0:11 
QuestionRetreiving a list of network computer Pin
R4yth3ron12-Mar-13 6:55
R4yth3ron12-Mar-13 6:55 
AnswerRe: Retreiving a list of network computer Pin
Ingo12-Mar-13 7:08
Ingo12-Mar-13 7:08 
GeneralRe: Retreiving a list of network computer Pin
R4yth3ron12-Mar-13 7:18
R4yth3ron12-Mar-13 7:18 
AnswerRe: Retreiving a list of network computer Pin
Ingo17-Mar-13 22:56
Ingo17-Mar-13 22:56 
AnswerRe: Retreiving a list of network computer Pin
OriginalGriff12-Mar-13 21:08
mveOriginalGriff12-Mar-13 21:08 
QuestionError C# : Conversion failed when converting the nvarchar value 'd' to data type int. Pin
Hodamdi11-Mar-13 22:31
Hodamdi11-Mar-13 22:31 
AnswerRe: Error C# : Conversion failed when converting the nvarchar value 'd' to data type int. Pin
Karthik Harve11-Mar-13 22:48
professionalKarthik Harve11-Mar-13 22:48 
AnswerRe: Error C# : Conversion failed when converting the nvarchar value 'd' to data type int. Pin
Abhinav S12-Mar-13 2:31
Abhinav S12-Mar-13 2:31 
AnswerRe: Error C# : Conversion failed when converting the nvarchar value 'd' to data type int. Pin
Bernhard Hiller12-Mar-13 4:55
Bernhard Hiller12-Mar-13 4:55 
QuestionHOW I PROVIDE SECURITY OF MY DLL FILE FROM END USER Pin
seema jadhav11-Mar-13 21:09
seema jadhav11-Mar-13 21:09 
SuggestionRe: HOW I PROVIDE SECURITY OF MY DLL FILE FROM END USER Pin
Richard MacCutchan11-Mar-13 22:51
mveRichard MacCutchan11-Mar-13 22:51 
AnswerRe: HOW I PROVIDE SECURITY OF MY DLL FILE FROM END USER Pin
Pete O'Hanlon11-Mar-13 23:15
mvePete O'Hanlon11-Mar-13 23:15 
AnswerRe: HOW I PROVIDE SECURITY OF MY DLL FILE FROM END USER Pin
Bernhard Hiller12-Mar-13 5:00
Bernhard Hiller12-Mar-13 5:00 

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.