Two thread interactive program

This is a discussion on Two thread interactive program within the C Programming forums, part of the General Programming Boards category; Hey everyone, I'm writing a two thread application. First thread: Requests for commands and processes them. Second thread: Periodically, for ...

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    46

    Arrow Two thread interactive program

    Hey everyone,

    I'm writing a two thread application.

    First thread:
    Requests for commands and processes them.

    Second thread:
    Periodically, for example every 10 seconds, shows all items in the list.

    Question:

    How to design the application in such way that it doesn't get interrupted when the user is typing a command, or maybe there is a different approach to this kind of application?

    Any help welcome!

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    If you're worried about the second thread taking over the screen when the user is entering data you need to design some form of interprocess communication to block the second thread unless the first is idle for some period of time.

    Alternatively you can regionalize the screen so that user input occurs in one section and the timed reports appear in a different area.

    The actual method you use to do this will be different for each OS and will depend in large part upon the multitasking libraries you are using.

  3. #3
    Registered User
    Join Date
    Nov 2009
    Posts
    46
    yes, that's exactly what i was wondering about..

    can u tell me about the alternative method? how do i organize it in CLI?

    Thanks!

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by r00t View Post
    yes, that's exactly what i was wondering about..

    can u tell me about the alternative method? how do i organize it in CLI?

    Thanks!
    This is where you need to make decisions about where you want things to happen....

    For example you may want the timed output on the right while the operator works on the left... so you arrange your display statements to locate the cursor on a certain character before each line...

    You might want the operator to work on the bottom half while your data prints out on the top half... this to is simply a matter of moving the cursor to the correct location before printing...

    Scrolling a split screen is going to be a software task, but it is all doable

  5. #5
    Registered User
    Join Date
    Nov 2009
    Posts
    46
    Scrolling a split screen is going to be a software task, but it is all doable
    What do you mean a software task?

    Is it possible to provide an example ?

  6. #6
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by r00t View Post
    What do you mean a software task?

    Is it possible to provide an example ?
    Unless you have screen libraries to split scroll the screen (i.e. scroll one region but not the rest) you're going to have to write that code into your program.

    I'm sorry, I don't have an example on hand...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. API Thread HEADACHE
    By WaterNut in forum Windows Programming
    Replies: 11
    Last Post: 01-16-2007, 10:10 AM
  2. Inserting text into MDI program
    By Rutabega in forum Windows Programming
    Replies: 0
    Last Post: 12-23-2005, 11:25 AM
  3. Simple thread object model (my first post)
    By Codeplug in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2004, 11:34 PM
  4. A program thread...
    By Sebastiani in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 05-06-2002, 11:19 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21