Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6351051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:55:39+00:00 2026-05-24T21:55:39+00:00

I’d like to know how to link the data received via serialport to the

  • 0

I’d like to know how to link the data received via serialport to the function calling it in the main UI.

I would like the UI to send out data from the serialport, then suspend the thread or wait until data is received via the serialport thread, before continuing the main UI thread.

I am told that thread.suspend() is not a safe function to use, I tried it together with thread.resume, but failed.

Should I be looking at lock/mutex?

Or EventWaitHandles?

I am thoroughly confused! I am not familiar with threading so any help would be much appreciated! Thank you.

Code below:

public static int SerialCOM_Read(uint tRegisterAddress, out byte[] tRegisterValue, uint nBytes)
{

      int retVal = 1;

      tRegisterValue = new byte[nBytes]; 

     byte[] nBytesArray = new byte[4];

        NBytes = nBytes; 


        try {

            ReadFunction = true; 
            YetToReceiveReadData = true; 
        byte[] registerAddress = BitConverter.GetBytes(tRegisterAddress);

        int noOfBytesForRegAdd = 1;

        if (registerAddress[3] > 0) noOfBytesForRegAdd = 4;
        else if (registerAddress[2] > 0) noOfBytesForRegAdd = 3;
        else if (registerAddress[1] > 0) noOfBytesForRegAdd = 2;

        nBytesArray = BitConverter.GetBytes(nBytes);
        {

         Append_Start();
         Append_Operation_with_NoOfBytesForRegAdd(OPERATION.I2C_READ, noOfBytesForRegAdd);
         Append_RegAdd(noOfBytesForRegAdd, tRegisterAddress);
      Append_NoOfBytesOfData(nBytesArray); 

        Send_DataToWrite();

     //Need to Suspend Thread here and Continue once the 
     //ReadData[i] global variable has been assigned.

     for(int i=0; i<nBytes; i++)
tRegisterValue[i] = ReadData[i]; 
     }
         catch(Exception ex) {}

         return retVal;

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T21:55:39+00:00Added an answer on May 24, 2026 at 9:55 pm

    If you are going to block the UI thread then there’s no point in using the DataReceived event. Simply call SerialPort.Read/Line() directly. The delays this can cause in the user interface responsiveness are usually undesirable but it is definitely a lot easier to get going.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to run a str_replace or preg_replace which looks for certain words
I know there's a lot of other questions out there that deal with this
I want to construct a data frame in an Rcpp function, but when I
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I would like to count the length of a string with PHP. The string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.