Results 1 to 5 of 5

Thread: threading

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2003
    Location
    Porto Alegre, RS
    Posts
    210

    threading

    to use threads, i could implement all methods on the same file?

    i mean, i have one file with 5 diferent methods, all of them have a "while true" inside it, and inside the "While true" i have a "Thread.CurrentThread.Sleep(5000)" to sleep for 5 seconds each thread. Have some problem with it??

    I think it have some problem, because it uses betwen 95% and 98% of the cpu!

    Thank you,
    Guilherme Costa

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Loop is very CPU intense especially if just continuously loops and checks for a value. This is made worse if you are running all 5 methods at the sametime via threading. What is it you are trying to do? Or what exactly is the problem?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2003
    Location
    Porto Alegre, RS
    Posts
    210
    i have 4 serial ports connected to the PC, and i have to monitor some data that i recieve via serial.

    that's why i have this four methodes, the fith will be soon implemented!

    Thanks for any help,
    Guilherme Costa

  4. #4
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    instead of thread.sleep() why dont you just put all the code together in the same thread?
    \m/\m/

  5. #5
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Alternatively you could just use a single timer and have it poll each method once per tick.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width