Visual C++ Multi-Threading (Please please HELP)
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Visual C++ Multi-Threading (Please please HELP)

Hybrid View

  1. #1
    Join Date
    Aug 2011
    Posts
    19

    Visual C++ Multi-Threading (Please please HELP)

    Hi All,

    This is the problem I have. I have one simple Windows Form application, and I have two buttons.

    With the first button, I am writing to a disk drive (using fwrite), and this part works just fine. Off course depending on the transfer size (Bytes/sec) and the size of the target disk, this may actually take several minutes.
    So, I intended to create a second button, so that if the user decided to stop writing to the disk, he can click on second button to stop the transfer.
    But, I have the hardest time doing this, because I don't know much about multi-threading. I don't know how to click button #2, while button number one is still in action.
    I have been browsing the web, and looking for solution and trying to try different things for a long time, and I cannot find a solution for my problem.

    I would really really appreciate some help with my issue.

    Thanks,
    --Rudy

  2. #2
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,583

    Re: Visual C++ Multi-Threading (Please please HELP)

    Ok, unlike your original post in the C++/CLI section, this really explains why you want multithreading, and in fact that's a common and adequate application of it.

    You may want to have a look at this old thread: http://forums.codeguru.com/showthrea...rsor-correctly It's about my very first C++/CLI toy project and involves multithreading in the context of a lengthy file operation. I got great help from two really arrived forum members back then. (However, I admit the code you'll find there contains some things I'd do differently nowadays.)

    The code in that thread doesn't implement a button to cancel the operation, but IIRC it's discussed how to implement it.

    If you have further questions, feel free to ask. (But please post in this thread here then instead of digging up the old one.)
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  3. #3
    Join Date
    Aug 2011
    Posts
    19

    Re: Visual C++ Multi-Threading (Please please HELP)

    Thanks a lot.
    I have to deliver some working code by Monday. So, even though I really want to dig into the Multi-Threading, but I was able to get it resolved with the DoEvent for now.
    I really appreciate your help. In few weeks, I would really like to sit down and read more about this Multi-Threading, because I totally agree that the long term solution is the Multi-Threading not the DoEvent one.
    Could you please point me in some good materials for multi-threading for me to read on?
    I am a type of person that I have to see some code and play with it until I learn it, or else I get lost into reading.
    Do you have some Multi-Threading example code that I can look at?
    I really appreciate your help.

    Thanks,
    -Rudy

  4. #4
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,583

    Re: Visual C++ Multi-Threading (Please please HELP)

    Ok, Application::DoEvents() is sort of "fake multithreading", I don't really like it and have never used it except rarely and temporarily in experimental contexts, but, admittedly, it can quickly get you a working solution sometimes.

    I'm afraid basic multithreading examples in C++/CLI are hard to find, since C++/CLI is a niche programming language, in particular when it comes to general-purpose applications. The toy project discussed in the (admittedly lengthy) thread I linked to above is attached to post #35, ready to download and play with. It has been created with VC++ 2010, so it may need initial conversion when used with other versions. And, in contrast to what I stated above, it does implement the cancel button.

    IIRC there are examples of multithreading in other threads in this section, but nothing so elaborate.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  5. #5
    Join Date
    Aug 2011
    Posts
    19

    Re: Visual C++ Multi-Threading (Please please HELP)

    Nice.
    I didn't know the code is there ready to download. I will certainly do that, and will look in detail into it, and I may ask you questions, if I come across something that I don't understand.
    Thank you so much again for your help.
    --Rudy

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center