Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Resume and suspend thread

Resume and suspend thread

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestioncareer
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RockyJames
    wrote on last edited by
    #1

    Hi, I wrote a DLL,for serial port communication.When i open the port i have created a thread in suspended mode,even created Events in same function later on i have resumed the thread,i wrote callback function.This callback function is called ,when ever the recevie event is set,when ever i get data from the instrument.Then i read the data send it to client application through Firefunction,i.e by connection points.I have three commands CMDONE,CMDTWO and CMTHREE.I have set a BOOL variable blntwo=FALSE;if( blntwo==TRUE),i will read the data using callbackfuntion,if not i will return from the function ,even if the control comes into it. First i send CMDONE i get "OK" reply back from instrument.For this i wrote the data onto the port and read "OK" directly instead of using serailback function. Then i will send CMDTWO,here i just write the data on the port and set blntwo=TRUE;.I will be getting data constantly from instrument,i will read this data using callback function ,then send this data to client application through Fire function. Then i will send CMDTHREE,i am setting blntow=FALSE,here i want to suspend the thread,so that reading is not done by Serialcall function,Instead i want to read the data directly here when i send CMDTHREE.But this is not happening..May be bec of synchronization problem..how to solve it..?If i don`t suspend the thread application is crashing.. Thanks in before James

    M 1 Reply Last reply
    0
    • R RockyJames

      Hi, I wrote a DLL,for serial port communication.When i open the port i have created a thread in suspended mode,even created Events in same function later on i have resumed the thread,i wrote callback function.This callback function is called ,when ever the recevie event is set,when ever i get data from the instrument.Then i read the data send it to client application through Firefunction,i.e by connection points.I have three commands CMDONE,CMDTWO and CMTHREE.I have set a BOOL variable blntwo=FALSE;if( blntwo==TRUE),i will read the data using callbackfuntion,if not i will return from the function ,even if the control comes into it. First i send CMDONE i get "OK" reply back from instrument.For this i wrote the data onto the port and read "OK" directly instead of using serailback function. Then i will send CMDTWO,here i just write the data on the port and set blntwo=TRUE;.I will be getting data constantly from instrument,i will read this data using callback function ,then send this data to client application through Fire function. Then i will send CMDTHREE,i am setting blntow=FALSE,here i want to suspend the thread,so that reading is not done by Serialcall function,Instead i want to read the data directly here when i send CMDTHREE.But this is not happening..May be bec of synchronization problem..how to solve it..?If i don`t suspend the thread application is crashing.. Thanks in before James

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      Without code it's tough to know what's going on. I'd be worried about suspending the thread from another thread because you don't know where the thread is going to stop. Again, I don't know your code, but maybe a notifying the thread (through a simple bool flag even) to ignore data until a reply from CMDTHREE is received or something along those lines. If the thread is receiving event-driven data and you suspend it then how do you know you're in a correct state to read data directly?

      R 1 Reply Last reply
      0
      • M Mark Salsbery

        Without code it's tough to know what's going on. I'd be worried about suspending the thread from another thread because you don't know where the thread is going to stop. Again, I don't know your code, but maybe a notifying the thread (through a simple bool flag even) to ignore data until a reply from CMDTHREE is received or something along those lines. If the thread is receiving event-driven data and you suspend it then how do you know you're in a correct state to read data directly?

        R Offline
        R Offline
        RockyJames
        wrote on last edited by
        #3

        Hi, Thanks for the reply,as u have asked for the code,i have downloaded a project from codeproject http://www.codeproject.com/com/CompCateg2.asp[^] In this i am using only serialport communication module,to existing code i have added my three functions CMDONE,CMDTWO,CMDTHREE,and if(blnTwo==TRUE) in serial callback function.please ask me any more information is required,bec i have to fix this problem. Thanks in before James

        M 1 Reply Last reply
        0
        • R RockyJames

          Hi, Thanks for the reply,as u have asked for the code,i have downloaded a project from codeproject http://www.codeproject.com/com/CompCateg2.asp[^] In this i am using only serialport communication module,to existing code i have added my three functions CMDONE,CMDTWO,CMDTHREE,and if(blnTwo==TRUE) in serial callback function.please ask me any more information is required,bec i have to fix this problem. Thanks in before James

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          RockyJames wrote:

          i have downloaded a project from codeproject

          You can ask Mr. Zak Howland (the author) yourself. There's a place for messages at the bottom of the article. Mark

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups