Problem with threading

This is a discussion on Problem with threading within the Windows Programming forums, part of the Platform Specific Boards category; Ok, i got my threading program to work i guess, but i had to change some of my code because ...

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    215

    Problem with threading

    Ok, i got my threading program to work i guess, but i had to change some of my code because it wouldnt work the right way with the threading. Lets say i called an if statment, and within that if statement i called the function that calls _beginthread. Well it would keep looping the if statement for some reason over and over again. I dont understand why that is. I got mos tof my code to work, but I had to change it to accomodate the threading.

  2. #2
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    Would you like to post some code?

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    I highly recommend Programming Applications for Microsoft Windows (Microsoft Programming Series) by Jeffrey Richter.

    Kuphryn

  4. #4
    Registered User
    Join Date
    May 2004
    Posts
    215
    Ok here is the problem with my program, I think it is because im using multi-threading.
    Anyways, the problem is, when the user clicks the station button in my program
    the command "sta" should be sent to the server, which it is. Then the server should
    send back the data which it does. I save the data in a file. It does that as well.
    What the command does is get the network, stations, and channels from the server, in the form
    of XX.XXX.XXX. So what i wanted to do is put the stations, networks, and channels in their
    own file to save each one. So i used a string tokenizer to do that, but my program keeps crashing
    I think it has something to do with using threading. But i could be wrong. But anyways
    the beginning of my code is sending "sta" to the server. it goes to the do_commands function
    and on line 230, the beginthread function starts. so we go into receive, and on line
    365, the server copies the data from the server. Then after all this is done we go back to the
    station function and we do the data_info function which does the tokenization, but
    theres something wrong with the threading thats causing the receive function to act weird.
    I can also upload you my program if you need it, its one file. This is also the last thing
    i need to fix with my program, and its the most stressful basically because I dont know what to
    do with it.

    Anyways, heres the site where my code is located.

    http://sourcepost.sytes.net/sourcevi...ource_id=15518

  5. #5
    Registered User
    Join Date
    May 2004
    Posts
    215
    I think I figured it out. thanks anyways!

  6. #6
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    You should consider explaining what the problem was and how you fixed it, to help any others who might suffer from the same problem and come a'searchin in the future.

  7. #7
    Registered User
    Join Date
    May 2004
    Posts
    215
    Oh well, I just used the debugger and I just put a counter in the receive function,and when it kept executing one statement the counter would remain 0, but when it finally broke out of the while loop, it would turn 1, and then we could execute the data_info function. and now it works

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 10:22 AM
  2. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  3. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  4. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  5. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 05:24 PM

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