How to use thread in c++ win 32

Pages: 12
Using the wxWidgets library does create GUI apps, but it is NOT true Win32 API programming. It is a framework. It is similar in approach to MFC or C#. The frameworks hide all the low-level detail work that Win32 API requires.

No wonder why the OP couldn't get my Win32 API code to work.
closed account (z05DSL3A)
wxWidgets has its own thread class
https://docs.wxwidgets.org/trunk/classwx_thread.html

but a note on that page says...
Note
In C++11 programs, consider using std::thread instead of this class.
My understanding of things is that any cross platform toolkit or application framework has to rely upon any specific platform's underlying programming interface. That would include Windows itself and C++ itself in the case of MS Windows as something riding upon the Win32 Api. The OP wanted to know about threading in Win32, although all the code he/she posted seemed to be C++ specific code.
Furry Guy said...


No wonder why the OP couldn't get my Win32 API code to work.


I'm extremely sympathetic to any of the experienced coders here who attempt to post whole compilable programs for new comers to attempt to build and learn from. I just attempted to use Visual Studio's IDE (VS2019) to build a fairly complex C++ example program which is a Win32 example of a multi-threaded (Worker thread and GUI thread) program. It took me like 45 minutes from start to finish to get a successful build without errors, and I guess I could be classified as a professional coder in that I started coding with Fortran in 1975 on mainframes, and have designed and written mission critical enterprise apps for large organizations which are still in use. I always work from the command line and it only takes a few seconds to build from there. I really feel bad for the young (or otherwise) folks trying to start out now.
freddie1, you're right that cross platform tools, even those of the standard C++ library, adapt to the local operation system. Stated backwards, the only way an operating system can perform a task is from it's interface, so any portable interface is designed to provide a common means of handling that task despite the specifics of the underlying operating system - there's just no other way to accomplish that.

That said, I sense a blurring of meaning. To us, win32 is an operating system API. To a student, it can mean Windows more generally.

I think that's where the conversation started, and how it may be viewed as spilling out all over the place.

At this point, really, the C++ libraries dealing with threading should be the goto method for any new code. It is portable by definition, it works, and it is based upon and close to as fast as any native approach, but doesn't suffer from many of the tedious trivial details.

The OP mentioned wxWidgets, which supports multiple operating systems and the OP may be thinking that the terms win32, Windows and the 64 bit counterparts to the Windows API are all interchangeable in a discussion.

We know they're not, and wxWidgets is, therefore, a framework approach to making a GUI application where the thread classes it uses are from an older generation of the framework, prior to C++11 (or C++0x for that matter).

Really, what the OP wanted was a way to thread in a style as "easy" as C#.

That's std::thread and the related materials.

Last edited on
Niccolo wrote:
To us, win32 is an operating system API. To a student, it can mean Windows more generally.

The OP mentioned wxWidgets, which supports multiple operating systems and the OP may be thinking that the terms win32, Windows and the 64 bit counterparts to the Windows API are all interchangeable in a discussion.

The OP also mentioned
I found that c # is easy to decompile so I determined to learn C++.
Decompile C# code?!?

Beginner's confusion over terminology, plus a likely Not English speaker language difficulty?

@Ba ranh, you want to learn C++ so I suggest you look at an online tutorial: Learn C++.
https://www.learncpp.com/
thanks everyone for helping me, i was using multithread 'std :: thread'
Good choice @Ba ranh

@Furry Guy, I think the OP was referring to that reverse engineering tactic which can produce a readable C# source from a compiled .NET application, which is also possible from Java (or other similar byte code compilations targeting a runtime engine like they do), which is considered a security risk and is, in part, the origin of the .NET obfuscation techniques for compiled code.

I sense that prompted the OP to consider something that wasn't as easily reverse engineered.

A simple example of C++ multithreading using the <thread> library:
https://stackoverflow.com/questions/266168/simple-example-of-threading-in-c
There's even a very simple example on this site in the C++ reference section.
There is indeed a number of thread samples here, freddie1, but I was amused by the back-and-forth posturing at the stackoverflow link since it was started before C++11 and <thread> was approved.
Last edited on
Topic archived. No new replies allowed.
Pages: 12