Results 1 to 9 of 9

Thread: Threads and streams in C++

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2001
    Location
    USA
    Posts
    6
    Does anyone know here I can find information on thread and stream programming in c++? I'm not a begginer in programming threads and streams, I have coded both in Visual Basic and java but I'm new to this topic in c++.
    J S GuitarSlinger

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    MSDN has plenty of info. Look up CreateThread in the Platform SDK.

    For streams, do you mean like iostreams? Or multimedia streaming?
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2001
    Location
    USA
    Posts
    6
    Streams to other computers through say tcp/ip and to multimedia devices would be great.
    J S GuitarSlinger

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    So Winsock programming then

    MSDN has some info, and this may help at planetsourcecode -- not checked it, though (i have a really slow connection)
    http://www.planet-source-code.com/vb...=1141&lngWId=3
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  5. #5

    Thread Starter
    New Member
    Join Date
    Feb 2001
    Location
    USA
    Posts
    6
    Thank you very much, Parksie.
    J S GuitarSlinger

  6. #6
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Okay...here's a quick example of threads:
    PHP Code:
    #include <windows.h>
    #include <iostream>

    using namespace std;

    DWORD __stdcall ThreadFunc(void *pParam) {
        
    cout << "In the thread!" << endl;

        
    Sleep(5000);

        return 
    0// Exit from thread
    }

    void main(int argcchar **argv) {
        
    unsigned long lThreadId;
        
    HANDLE hThread;
        
    hThread CreateThread(NULL0ThreadFuncNULL0, &lThreadId);

        if(
    hThread == NULL) {
            
    cout << "Could not create thread\n";
            return;
        }

        
    Sleep(2500);
        
    cout << "Main thread" << endl;
        
    Sleep(3000); // Give B a chance to finish

        
    CloseHandle(hThread);

    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  7. #7

    Thread Starter
    New Member
    Join Date
    Feb 2001
    Location
    USA
    Posts
    6
    Thanks again.
    J S GuitarSlinger

  8. #8
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Multithreading is one of the most complex areas of windows programming. Here is an example in Multithreading. (the comments are not in english).
    Attached Files Attached Files
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  9. #9
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Nice code Vlatko...very nice.

    ...not so sure about the MFC, though
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

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