Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. _beginthread / process.h

_beginthread / process.h

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
13 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F fx9200

    hello, i'am creating threads to run some listeners, i have an error which i have not understanded the compiler says that _beginthread is undeclared but i have included process.h ?? this is the code #include #include /* _beginthread, _endthread */ #include #include void main() { HANDLE hThread; unsigned threadID; // Create the second thread. hThread = (HANDLE)_beginthread( NULL, 0, &SecondThreadFunc, NULL, 0, &threadID ); // Wait until second thread terminates. If you comment out the line // below, Counter will not be correct because the thread has not // terminated, and Counter most likely has not been incremented to // 1000000 yet. WaitForSingleObject( hThread, INFINITE ); // Destroy the thread object. CloseHandle( hThread ); return 0; }

    D Offline
    D Offline
    Don Box
    wrote on last edited by
    #2

    Better use CreateThread().

    Come online at:- fitiyal@yahoo.com

    F 1 Reply Last reply
    0
    • D Don Box

      Better use CreateThread().

      Come online at:- fitiyal@yahoo.com

      F Offline
      F Offline
      fx9200
      wrote on last edited by
      #3

      i used it but when executing the function (with debugger) the parameter ( whose type is char*) pass directly to a NULL parameter . Note: the function is executing normally without thread !

      1 Reply Last reply
      0
      • F fx9200

        hello, i'am creating threads to run some listeners, i have an error which i have not understanded the compiler says that _beginthread is undeclared but i have included process.h ?? this is the code #include #include /* _beginthread, _endthread */ #include #include void main() { HANDLE hThread; unsigned threadID; // Create the second thread. hThread = (HANDLE)_beginthread( NULL, 0, &SecondThreadFunc, NULL, 0, &threadID ); // Wait until second thread terminates. If you comment out the line // below, Counter will not be correct because the thread has not // terminated, and Counter most likely has not been incremented to // 1000000 yet. WaitForSingleObject( hThread, INFINITE ); // Destroy the thread object. CloseHandle( hThread ); return 0; }

        H Offline
        H Offline
        Hamid Taebi
        wrote on last edited by
        #4

        Did you see example from this function in msdn?

        From the MSDN
        Example
        The following example uses _beginthread and _endthread.
        
        // crt_BEGTHRD.C
        // compile with: /MT /D "_X86_" /c
        #include 
        #include     /* _beginthread, _endthread */
        #include 
        #include 
        #include 
        ...
        ...
        

        _**


        **_

        WhiteSky


        F 1 Reply Last reply
        0
        • H Hamid Taebi

          Did you see example from this function in msdn?

          From the MSDN
          Example
          The following example uses _beginthread and _endthread.
          
          // crt_BEGTHRD.C
          // compile with: /MT /D "_X86_" /c
          #include 
          #include     /* _beginthread, _endthread */
          #include 
          #include 
          #include 
          ...
          ...
          

          _**


          **_

          WhiteSky


          F Offline
          F Offline
          fx9200
          wrote on last edited by
          #5

          this is exactly which i was talking about the problem is in this sample

          H 1 Reply Last reply
          0
          • F fx9200

            this is exactly which i was talking about the problem is in this sample

            H Offline
            H Offline
            Hamid Taebi
            wrote on last edited by
            #6

            You get this error "c:\C\1112\Main.cpp(29): error C3861: '_beginthread': identifier not found, even with argument-dependent lookup" Did you see this line in this example // compile with: /MT /D "_X86_" /c

            _**


            **_

            WhiteSky


            F 1 Reply Last reply
            0
            • H Hamid Taebi

              You get this error "c:\C\1112\Main.cpp(29): error C3861: '_beginthread': identifier not found, even with argument-dependent lookup" Did you see this line in this example // compile with: /MT /D "_X86_" /c

              _**


              **_

              WhiteSky


              F Offline
              F Offline
              fx9200
              wrote on last edited by
              #7

              i tryed to compile it wth this cmd line but the compiler (i tryed with cl.exe) didn't accept this !

              H 1 Reply Last reply
              0
              • F fx9200

                i tryed to compile it wth this cmd line but the compiler (i tryed with cl.exe) didn't accept this !

                H Offline
                H Offline
                Hamid Taebi
                wrote on last edited by
                #8

                Whats application type?

                _**


                **_

                WhiteSky


                F 1 Reply Last reply
                0
                • H Hamid Taebi

                  Whats application type?

                  _**


                  **_

                  WhiteSky


                  F Offline
                  F Offline
                  fx9200
                  wrote on last edited by
                  #9

                  win32 application :rolleyes:

                  H 1 Reply Last reply
                  0
                  • F fx9200

                    win32 application :rolleyes:

                    H Offline
                    H Offline
                    Hamid Taebi
                    wrote on last edited by
                    #10

                    Did you set /MT /D "_X86_" /c to runtime library

                    _**


                    **_

                    WhiteSky


                    1 Reply Last reply
                    0
                    • F fx9200

                      hello, i'am creating threads to run some listeners, i have an error which i have not understanded the compiler says that _beginthread is undeclared but i have included process.h ?? this is the code #include #include /* _beginthread, _endthread */ #include #include void main() { HANDLE hThread; unsigned threadID; // Create the second thread. hThread = (HANDLE)_beginthread( NULL, 0, &SecondThreadFunc, NULL, 0, &threadID ); // Wait until second thread terminates. If you comment out the line // below, Counter will not be correct because the thread has not // terminated, and Counter most likely has not been incremented to // 1000000 yet. WaitForSingleObject( hThread, INFINITE ); // Destroy the thread object. CloseHandle( hThread ); return 0; }

                      F Offline
                      F Offline
                      fx9200
                      wrote on last edited by
                      #11

                      How can i compile with /MT option ???

                      H D 2 Replies Last reply
                      0
                      • F fx9200

                        How can i compile with /MT option ???

                        H Offline
                        H Offline
                        Hamid Taebi
                        wrote on last edited by
                        #12

                        Right click in your project in solution Explorer ->select property->(Configuration properties)Open C/C++ ->code generation ->now you can see Runtime Library then select Multi-threaded Debug DLL (/MDd)

                        _**


                        **_

                        WhiteSky


                        1 Reply Last reply
                        0
                        • F fx9200

                          How can i compile with /MT option ???

                          D Offline
                          D Offline
                          David Crow
                          wrote on last edited by
                          #13

                          Open the Project Settings dialog (Alt+F7). Click the C/C++ tab. Select the Code Generation category. In the run-time library combobox, select Multithreaded (/MT) or Debug Multithreaded (/MTd).


                          "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

                          "Judge not by the eye but by the heart." - Native American Proverb

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups